博客园  :: 首页  :: 联系 :: 管理

Hook处理函数中lParam参数的处理

Posted on 2007-03-25 13:32  sunrack  阅读(969)  评论(0编辑  收藏  举报
LRESULT CALLBACK KeyboardProc(int iCode, WPARAM wParam, LPARAM lParam)
{
         KBDLLHOOKSTRUCT* pStruct = (KBDLLHOOKSTRUCT*)lParam;
 
         //Specifies the transition state.
         //The value is 0 if the key is pressed and 1 if it is being released.
         if(pStruct->flags != 0)
         {
              //不处理
         }
         else
         {
              //处理
         }
}
 
 
 
附:KBDLLHOOKSTRUCT Structure
 

The KBDLLHOOKSTRUCT structure contains information about a low-level keyboard input event.

Syntax

typedef struct {
DWORD vkCode;
DWORD scanCode;
DWORD flags;
DWORD time;
ULONG_PTR dwExtraInfo;
} KBDLLHOOKSTRUCT, *PKBDLLHOOKSTRUCT;

Members

vkCode
Specifies a virtual-key code. The code must be a value in the range 1 to 254.
scanCode
Specifies a hardware scan code for the key.
flags
Specifies the extended-key flag, event-injected flag, context code, and transition-state flag. This member is specified as follows. An application can use the following values to test the keystroke flags.
Value Purpose
LLKHF_EXTENDED Test the extended-key flag.
LLKHF_INJECTED Test the event-injected flag.
LLKHF_ALTDOWN Test the context code.
LLKHF_UP Test the transition-state flag.
0
Specifies whether the key is an extended key, such as a function key or a key on the numeric keypad. The value is 1 if the key is an extended key; otherwise, it is 0.
1-3
Reserved.
4
Specifies whether the event was injected. The value is 1 if the event was injected; otherwise, it is 0.
5
Specifies the context code. The value is 1 if the ALT key is pressed; otherwise, it is 0.
6
Reserved.
7
Specifies the transition state. The value is 0 if the key is pressed and 1 if it is being released.
time
Specifies the time stamp for this message, equivalent to what GetMessageTime would return for this message.
dwExtraInfo
Specifies extra information associated with the message.

Structure Information

Header Declared in Winuser.h, include Windows.h
Minimum operating systems Windows NT 4.0 SP3