问题描述
公共声明函数KeyState库"user32"(ByVal vkey只要长)作为整数
我在Visual Studio 2010的键状态函数中收到PInvoke错误.
如何解决.
它适用于VS2008,但不适用于VS2010
帮帮我
在此先感谢...
使用GetAsyncKeyState时出现此错误.
对PInvoke函数``KeyFrmApp!keyFrmApp.Form1 :: GetAsyncKeyState的调用"使堆栈不平衡.这很可能是因为托管PInvoke签名与非托管目标签名不匹配.请检查PInvoke签名的调用约定和参数.匹配目标非托管签名."
Public Declare Function KeyState Lib "user32" (ByVal vkey As Long) As Integer
I m getting a PInvoke error in Keystate Function in visual studio 2010.
how can it be solved.
It works on VS2008 but not in VS2010
help me
thanks in advance...
I get this error when using GetAsyncKeyState........
"A call to PInvoke function ''KeyFrmApp!keyFrmApp.Form1::GetAsyncKeyState'' 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."
推荐答案
Public Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Int32) As UShort
Usage:
Public Shared ReadOnly Property KeyStatus(ByVal Key As Keys) As Boolean
Get
If Key = Keys.LButton AndAlso My.Computer.Mouse.ButtonsSwapped Then
Key = Keys.RButton
ElseIf Key = Keys.RButton AndAlso My.Computer.Mouse.ButtonsSwapped Then
Key = Keys.LButton
End If
Return API.Devices.GetAsyncKeyState(Key) And &H8000US
End Get
End Property
上面的代码提供了键和鼠标按钮的状态.
Above code provide the status of the key and mouse button.
这篇关于Visual Studio 2010 PInvoke错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!