想把按键信息,和放开按键信息存储起来,
hook可以正常使用,wParam中存储的也是键盘信息
就是不知道“按键”和“放键”是什么?SetWindowsHookEx(WH_KEYBOARD,KeyboardProc,hInstance,0);
LRESULT WINAPI KeyboardProc(int nCode,WPARAM wParam,LPARAM lParam)
{

if( nCode >= 0 )
{
switch (nCode)
{
case WM_KEYDOWN://键按下
{
keys[wParam] = true;
return 0;                   } 
case WM_KEYUP:// 键抬起
{
keys[wParam] = false;
return 0;
                            }
case WM_SIZE:
}
   return CallNextHookEx(glhHook,nCode,wParam,lParam); 
}

解决方案 »

  1.   

    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.
      

  2.   

    具体情况具体对待,USB键盘和PS/2键盘的扫描码是不同的
      

  3.   

    HIWORD(lParam) & KF_UP
    结果是真表示是up
      

  4.   

    我记得键盘按键有三种信号
    1.某键按下
    2.某键按住
    3.某键抬起
    怎么这里只有
    KF_REPEAT        
    KF_UP            
      

  5.   


    第二个信号 你要用 GetKeyState()
    具体使用看 msdn