前些天看到一篇关于HOOK的文章,小弟对里面的2个参数不是很明白,看了帮助也是摸不清头绪啊
请各位高手帮忙,解答下
function   KeyboardHookHandler(iCode:   Integer;   wParam:   WPARAM;   lParam:   LPARAM):   LRESULT;   stdcall;   export;   
  const   
     _KeyPressMask   =   $80000000;   
  begin   
     Result   :=   0;   
     If   iCode   <   0   Then   
     begin   
         Result   :=   CallNextHookEx(hNextHookProc,   iCode,   wParam,   lParam);   
         Exit;   
     end;   
     if   ((lParam   and   _KeyPressMask)   =   0)   and   (GetKeyState(vk—Control)   <   0)   and   (wParam   =   Ord(′N′))   then   
     begin   
         Result   :=   1;   
         ....
          end;   
  end;   
===================================================================================================
我所要问的是if((lParam   and   _KeyPressMask)   =   0)这句话到底什么意思??我看了半天也看不懂,WPARAM,LPARAM
这2个参数到底怎么去用啊

解决方案 »

  1.   

    这个要弄明白还得你自己去看msdn
    lParam  参数包含很多信息  32位内存,内容描述包括:指定扩展键值,扫描码,上下文,重复次数
     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. if((lParam and _KeyPressMask) = 0)
    因为lParam 包含了很多信息, 并不是每个信息都是你要的
    lParam and $80000000, 是取第31位的值 0 表示按下, 1表示松开
    GetKeyState(vk_Control) < 0 表示Ctrl被按下, 
    wParam 表示按键的虚拟键值消息, 如 Vk_Control整段是有键盘被按下, 而且同时 control 的状态是处于按下, 而且当前按下的是 N 键