全局钩子安装成功可是回调函数没成效哪位大哥能帮我看下
钩子安装成功 可是检测不出 键盘码9 是什么原因 工程源码
Private Sub Form_Load()
hhook = SetWindowsHookEx(WH_KEYBOWN_LL, AddressOf myhook, App.hInstance, 0)
If hhook = 0 Then
End
Else
Print hhook
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
UnhookWindowsHookEx hhook
End Sub
模块源码
Public Declare Function CallNextHookEx Lib "user32" (ByVal hhook As Long, ByVal ncode As Long, ByVal wparam As Long, lparam As Any) As Long
Public Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hhook As Long) As Long
Public Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
'定义常量
Public Const WH_KEYBOARD_LL = 13
Public Const HC_ACTION = 0
Public hhook As Long
Public Function myhook(ByVal ncode As Long, ByVal wparam As Long, ByVal lparam As Long) As Long
If ncode = 0 Then
If wparam = WM_KEYDOWN Then
wparam = 9
MsgBox "22"
End If
End If
myhook = CallNextHookEx(hhook, ncode, wparam, lparam)
End Function