新手提问setwindowshookex
'模板内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 Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Public Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal ncode As Long, ByVal WParam As Long, lParam As Any) As Long
Public Const WH_KEYBOARD=2
Public Sub setkeyhook()
keyhookm = SetWindowsHookEx(WH_KEYBOARD, AddressOf keyhook, App.hInstance, 0)
End Sub
Public Sub unhook()
UnhookWindowsHookEx (keyhookm)
End Sub
Public Function keyhook(ByVal ncode As Long, ByVal WParam As Long, ByVal ) as long
Static a As Integer
a=a+1
form1.caption=a
CallNextHookEX keyhookm,ncode , WParam , lParam
end function
'窗体
Private Sub Command1_Click()
call setkeyhook
End Sub
Private Sub Command2_Click()
call unhook
End Sub
为什么运行后按键无反应 键盘钩子 --------------------编程问答-------------------- 快来帮帮我啊 --------------------编程问答-------------------- 来人啊 --------------------编程问答-------------------- 帮帮忙啊 大侠们 --------------------编程问答-------------------- Public Function keyhook(ByVal ncode As Long, ByVal WParam As Long, ByVal ) as long
就你这代码能编译么? --------------------编程问答--------------------
我只是复制的时候少复制了点,后来没补全 我代码是全的 就是不能运行 --------------------编程问答-------------------- 请加上Option Explicit,因为你没有定义变量keyhookm,请在定义一个模块变量keyhookm…… --------------------编程问答--------------------
还是没用 --------------------编程问答-------------------- 我知道了 win7测试这段代码有问题 我在虚拟机上测试没问题 --------------------编程问答-------------------- 只有Xp,Xp测试可以,没有win7,没办法帮你测试了…… --------------------编程问答-------------------- http://download.csdn.net/detail/veron_04/1860777
补充:VB , API