VS 10 Ultimate pinvokestackimbalance detected

August 13, 2011 at 04:24:54
Specs: Windows 7, AMD X4 2.5
I'm trying to create a project with Visual Basic , and i meet this problem : pinvokestackimbalance was detected GetAsyncKeyState(i) can't stick with the " ) " i don't know what it mean and here's the project :
Public Class Form1
Dim result As Integer
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
For i = 1 To 255
result = 0
result = GetAsyncKeyState(i)
If result = -32767 Then
TextBox1.Text = TextBox1.Text + Chr(i)
End If
Next i
End Sub
End Class

See More: VS 10 Ultimate pinvokestackimbalance detected

Report •

August 13, 2011 at 05:25:49
It means your Declare statement is messed up. pinvoke.net says the correct signature is:
<DllImport("user32.dll")> _
Public Shared Function GetAsyncKeyState(ByVal vKey As System.Windows.Forms.Keys) As Short
End Function

How To Ask Questions The Smart Way

Report •

August 13, 2011 at 17:57:31
so where i have to change?

Report •

August 13, 2011 at 18:27:54
here's the detail problem how it saids : A call to PInvoke function 'WindowsApplication1!WindowsApplication1.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.

(result = GetAsyncKeyState(i) )

Report •

Related Solutions

Ask Question