- 分享
- 0
- 人气
- 0
- 主题
- 62
- 帖子
- 6367
- UID
- 51295
- 积分
- 3715
- 阅读权限
- 21
- 注册时间
- 2006-11-21
- 最后登录
- 2022-1-19
- 在线时间
- 3699 小时
|
我只是想知道我的parameter有没有错,有时API一点点错他就出现exception
因为exception好像跟我讲parameter有错,找了很久都找不到
我刚刚弄了GUI的,
Imports System.Runtime.InteropServices
Public Class Form1
Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, ByVal rectangle As RECT) As Boolean 'rectangle = receive handle's rectangle RECT,boolean = sucess or fail
Structure RECT
Dim x1 As Long
Dim y1 As Long
Dim x2 As Long
Dim y2 As Long
End Structure
<DllImport("user32.dll", CharSet:=CharSet.Auto, ExactSpelling:=True)> _
Public Shared Function GetForegroundWindow() As IntPtr
End Function
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim r As RECT
Dim b As Boolean = GetWindowRect(GetForegroundWindow(), r) ’<- 这里exception
ListBox1.Items.Add(GetForegroundWindow.ToString & " - " & r.x1 & "," & r.y1 & " | " & r.x2 & "," & r.y2 & "(" & b & ")")
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
A call to PInvoke function 'GetWindowRectangle!GetWindowRectangle.Form1::GetWindowRect' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature. |
|