| 查看: 768 | 回复: 6 | |||
| 当前主题已经存档。 | |||
| 当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖 | |||
[交流]
【原创】关于Low Level Keyboard Hook,万恶的SDK啊~~
|
|||
|
今天要做点事情,需要屏蔽Win键,于是想到用WH_KEYBOARD_LL,随便看了下VS6.0自带的MSDN里LowLevelKeyboardProc的描述: The LowLevelKeyboardProc hook procedure is an application-defined or library-defined callback function used with the SetWindowsHookEx function. The system calls this function every time a new keyboard input event is about to be posted into a thread input queue. The keyboard input can come from the local keyboard driver or from calls to thekeybd_event function. If the input comes from a call to keybd_event, the input was "injected". 于是写了类似下面的代码: void f() { HHOOK hHook = NULL; HANDLE hThread = NULL; __try { hHOOK = SetWindowHookExhInstance,WH_KEYBOARD_LL,LowLevelKeyboardProc,0); if(NULL == hHook) __leave; hThread=(HANDLE) _beginthread(.......); if ((HANDLE)1 == hThread) __leave; WaitForSingleObject(hThread); } __finally { if (NULL != hThread) CloseHandle(hThread); if (NULL != hHook) UnhookWindowsHookEx(hHook); } } 结果发现,安装的HOOK不起作用,研究了很久也不明白怎么回事,正在郁闷中,突然看到Win2K3的SDK Documentation里对LowLevelKeyboardProc的描述是: The LowLevelKeyboardProc hook procedure is an application-defined or library-defined callback function used with the SetWindowsHookEx function. The system calls this function every time a new keyboard input event is about to be posted into a thread input queue. The keyboard input can come from the local keyboard driver or from calls to the keybd_event function. If the input comes from a call to keybd_event, the input was "injected". However, the WH_KEYBOARD_LL hook is not injected into another process. Instead, the context switches back to the process that installed the hook and it is called in its original context. Then the context switches back to the application that generated the event. 天啊,平白无故的多出来一段,真是万恶的SDK啊~~! |
» 猜你喜欢
售SCI一区文章,我:8.O.551.O.5.4,科目全,可伽急
已经有6人回复
售SCI文章,我:8O.5.5.1O.54,科目全,可十急
已经有8人回复
售SCI文章,我:8O.5.5.1O.54,科目全,可十急
已经有5人回复
售SCI一区T0P文章,我:8O.55.1.O.5.4,科目齐全,可+急
已经有10人回复
售一区SCI文章T0P,我:8O.551.O54,科目全,可十急
已经有6人回复
售SCI一区T0P文章,我:8O.55.1.O.54,科目全,可伽急
已经有9人回复
售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急
已经有8人回复
国社科又开始会评了,不知道这次命运如何
已经有14人回复
售SCI一区文章,我:8.O.55.1.O.54,科目齐全,可伽急
已经有8人回复
麻烦专家们看看评委们的意见(F口面上)
已经有13人回复


4楼2009-09-10 21:36:48

2楼2009-09-10 18:54:17

3楼2009-09-10 19:48:13

5楼2009-09-11 00:04:32










回复此楼
30