注册 登录
编程论坛 VB6论坛

全局钩子安装成功可是回调函数没成效哪位大哥能帮我看下

li86791177 发布于 2013-05-08 19:36, 570 次点击
钩子安装成功 可是检测不出 键盘码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
1 回复
#2
li867911772013-05-08 20:43
看到的大哥研究过懂得大哥回复下  就是在钩子检测键盘的一个按键检测不出来 放心不是搞马 是热键暂停程序
1