|
-
Dec 9th, 2001, 03:18 PM
#1
Thread Starter
Addicted Member
Error With API call
I Have the following code:
Public Declare Function keybd_event Lib "user32" (ByVal bVk _
As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)
Public Sub ScreenCapture()
keybd_event vbKeySnapshot, 1, 0, 0
End Sub
I AM GETTING THE FOLLOWING ERROR:
Bad DLL Calling Convention (Error 49)
Does anyone know why???? ..... as far as i know, I am calling the function correctly..... (i have also tried:
Call keybd_event (vbKeySnapshot, 1, 0 ,0) but it gives the same error!)
To protect time is to protect everything...
-
Dec 9th, 2001, 03:27 PM
#2
PowerPoster
see if this example works for you
VB Code:
Const VK_H = 72
Const VK_E = 69
Const VK_L = 76
Const VK_O = 79
Const KEYEVENTF_EXTENDEDKEY = &H1
Const KEYEVENTF_KEYUP = &H2
Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Sub Form_KeyPress(KeyAscii As Integer)
'Print the key on the form
Me.Print Chr$(KeyAscii);
End Sub
Private Sub Form_Paint()
'Clear the form
Me.Cls
keybd_event VK_H, 0, 0, 0 ' press H
keybd_event VK_H, 0, KEYEVENTF_KEYUP, 0 ' release H
keybd_event VK_E, 0, 0, 0 ' press E
keybd_event VK_E, 0, KEYEVENTF_KEYUP, 0 ' release E
keybd_event VK_L, 0, 0, 0 ' press L
keybd_event VK_L, 0, KEYEVENTF_KEYUP, 0 ' release L
keybd_event VK_L, 0, 0, 0 ' press L
keybd_event VK_L, 0, KEYEVENTF_KEYUP, 0 ' release L
keybd_event VK_O, 0, 0, 0 ' press O
keybd_event VK_O, 0, KEYEVENTF_KEYUP, 0 ' release O
End Sub
-
Dec 10th, 2001, 07:39 AM
#3
Junior Member
The error is generated by VB. VB just knows that your code never works. You might change the 0 in 0& or ByVal 0 or ByVal 0&. The & is normally never used in VB anymore, but forces a value to be Long, not integer. It's needed sometimes. Hopes this does the trick.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|