在网上看到有这样一段代码(部分代码),不清楚LauncherHook中的wParam及lParam中到底指的是什么,还有 if(nCode==HC_ACTION)
{
if(lParam & 0x80000000)
不知道是什么意思?哪位大侠讲讲吧?谢谢啦!
DllExport void WINAPI InstallLaunchEv()
{
Hook=(HHOOK)SetWindowsHookEx(WH_KEYBOARD,(HOOKPROC)LauncherHook,theApp.m_hInstance,0);
} LRESULT CALLBACK LauncherHook(int nCode,WPARAM wParam,LPARAM lParam)
{
LRESULT Result=CallNextHookEx(Hook,nCode,wParam,lParam);
if(nCode==HC_ACTION)
{
if(lParam & 0x80000000)
{
char c[1];
c[0]=wParam;
SaveLog(c);
}
}
return Result;
}

解决方案 »

  1.   

    HC_ACTION:参数wParam 和lParam 包含了键盘消息的信息。
    wParam:键盘敲打所产生的键盘消息,键盘按键的虚拟代码。
    lParam:包含了消息细节。
    lParam & 0x80000000 按了键盘键。
      

  2.   

    我想了解lParam中的具体细节,lParam指向内存中的数据到底是什么结构。比如下面的MouseProc中的lParam可以转化为MOUSEHOOKSTRUCT FAR *结构,上面键盘钩子lParam可以转化为什么结构啊?还有参数nCode指的是什么?
    glhHook=SetWindowsHookEx(WH_MOUSE,MouseProc,glhInstance,0); 
    LRESULT WINAPI MouseProc(int nCode,WPARAM wparam,LPARAM lparam) 

    LPMOUSEHOOKSTRUCT pMouseHook=(MOUSEHOOKSTRUCT FAR *) lparam; 
    if (nCode>=0) 
    { ......
      

  3.   

    WH_KEYBOARD的lParam没有结构,是用位标示的。
    [in] Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag. For more information about the lParam parameter, see Keystroke Message Flags. This parameter can be one or more of the following values. 
    0-15
    Specifies the repeat count. The value is the number of times the keystroke is repeated as a result of the user's holding down the key.
    16-23
    Specifies the scan code. The value depends on the OEM.
    24
    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.
    25-28
    Reserved.
    29
    Specifies the context code. The value is 1 if the ALT key is down; otherwise, it is 0.
    30
    Specifies the previous key state. The value is 1 if the key is down before the message is sent; it is 0 if the key is up.
    31
    Specifies the transition state. The value is 0 if the key is being pressed and 1 if it is being released.
      

  4.   

    我在csdn上看到nCode还有可能为另外一个值HC_NOREMOVE,不过,不知道HC_NOREMOVE在什么情况下使用,是不是用到PeekMessag函数的时候使用nCode==HC_NOREMOVE?还有没有什么别的情况啊?