V
Vic Joseph
I'm trying to get information about the window of an external program. I
understand that I need to use API functions to do this, but somehow I cannot
get them to work. Whenever I try to use the handle (assuming I have found it
correctly using the FindWindow function) I get the error: "A call to PInvoke
function '...FlashWindow' has unbalanced the stack. This is likely because
the managed PInvoke signature does not match the unmanaged target
signature." Can anyone tell me what I am doing wrong?
Here's an example of the code, which tries to flash the Calculator.exe
window once:
'DECLARE API FUNCTIONS
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function FlashWindow Lib "user32" Alias "FlashWindow" (ByVal hwnd As
Long, ByVal bInvert As Long) As Long
'TEST THE FUNCTIONS
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim wHandle As Long
wHandle = WindowFinder.FindWindow("", "Calculator")
'THIS IS WHERE I GET THE ERROR:
If wHandle <> "" Then FlashWindow(wHandle, 1)
End Sub
thanks in advance en vriendelijke groet, Vic Joseph
understand that I need to use API functions to do this, but somehow I cannot
get them to work. Whenever I try to use the handle (assuming I have found it
correctly using the FindWindow function) I get the error: "A call to PInvoke
function '...FlashWindow' has unbalanced the stack. This is likely because
the managed PInvoke signature does not match the unmanaged target
signature." Can anyone tell me what I am doing wrong?
Here's an example of the code, which tries to flash the Calculator.exe
window once:
'DECLARE API FUNCTIONS
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function FlashWindow Lib "user32" Alias "FlashWindow" (ByVal hwnd As
Long, ByVal bInvert As Long) As Long
'TEST THE FUNCTIONS
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim wHandle As Long
wHandle = WindowFinder.FindWindow("", "Calculator")
'THIS IS WHERE I GET THE ERROR:
If wHandle <> "" Then FlashWindow(wHandle, 1)
End Sub
thanks in advance en vriendelijke groet, Vic Joseph