各位达人,我想在vb.net2005中获得鼠标的坐标值。但在执行时却弹出错误…… 请各位达人帮忙!季度感谢……
下面是代码
Public Class Form1 Private Structure POINTAPI '定义点(Point)结构
Dim X As Long '点在X坐标(横坐标)上的坐标值
Dim Y As Long '点在Y坐标(纵坐标)上的坐标值
End Structure Private Declare Function GetCursorPos Lib "user32" (ByVal lpPoint As POINTAPI) As Long Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
Timer1.Enabled = True
End Sub Sub PrintCursorPos()
Dim dl As Long
Dim MyPoint As POINTAPI
dl& = GetCursorPos(MyPoint) '调用函数,获取屏幕鼠标坐标
Label1.Text = "当前横坐标:" & Str(MyPoint.X)
Label2.Text = "当前纵坐标:" & Str(MyPoint.Y)
End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
PrintCursorPos()
End SubEnd Class
提示错误对 PInvoke 函数“test!test.Form1::GetCursorPos”的调用导致堆栈不对称。原因可能是托管的 PInvoke 签名与非托管的目标签名不匹配。请检查 PInvoke 签名的调用约定和参数与非托管的目标签名是否匹配。实在不明白…… 请各位达人解释!
下面是代码
Public Class Form1 Private Structure POINTAPI '定义点(Point)结构
Dim X As Long '点在X坐标(横坐标)上的坐标值
Dim Y As Long '点在Y坐标(纵坐标)上的坐标值
End Structure Private Declare Function GetCursorPos Lib "user32" (ByVal lpPoint As POINTAPI) As Long Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
Timer1.Enabled = True
End Sub Sub PrintCursorPos()
Dim dl As Long
Dim MyPoint As POINTAPI
dl& = GetCursorPos(MyPoint) '调用函数,获取屏幕鼠标坐标
Label1.Text = "当前横坐标:" & Str(MyPoint.X)
Label2.Text = "当前纵坐标:" & Str(MyPoint.Y)
End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
PrintCursorPos()
End SubEnd Class
提示错误对 PInvoke 函数“test!test.Form1::GetCursorPos”的调用导致堆栈不对称。原因可能是托管的 PInvoke 签名与非托管的目标签名不匹配。请检查 PInvoke 签名的调用约定和参数与非托管的目标签名是否匹配。实在不明白…… 请各位达人解释!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货