全部博文(788)
分类:
2008-11-27 21:16:49
我不想搞出个DLL得方法,想使用一个文件。
不用DLL要钩住其他程序的按键,只能用日志钩子。
具体用法请看这里:
blog.csdn.net/linzhengqun
找钩子及其应用。
hookHandle := SetWindowsHookEx(WH_KEYBOARD, @KeyboardCallback, HInstance, threadId);
这一行代码,用了HInstance,后面一个参数就要设置为0 ,如果后面一个参数设置为险程ID,那么前一个参数就要设置成0
下面是正确的
hookHandle := SetWindowsHookEx(WH_KEYBOARD, @KeyboardCallback, 0, GetCurrentThreadID);
hookHandle := SetWindowsHookEx(WH_KEYBOARD, @KeyboardCallback, HInstance, 0);
上面的可能还有点不清楚,帮助里面是这么说的
hMod
Identifies the DLL containing the hook procedure pointed to by the lpfn parameter. The hMod parameter must be set to NULL if the dwThreadId parameter specifies a thread created by the current process and if the hook procedure is within the code associated with the current process.
dwThreadId
Specifies the identifier of the thread with which the hook procedure is to be associated. If this parameter is zero, the hook procedure is associated with all existing threads.