我想屏蔽鼠标和除了ESC以外键盘上所有的按键。用SetWindowsHookEx如何编写?给分

解决方案 »

  1.   


    function HookProc(iCode:Integer;wParam:wParam;lParam:lParam):LRESULT;stdcall;
    begin
     Result:=0;
     if iCode < 0 then begin
       Result := CallNextHookEx(hHook,iCode,wParam,lParam);
       exit;
     end;
     if (iCode = HC_ACTION) and (pEventMSG(lParam)^.message = 257) then begin //键盘放开
        if pEventMSG(lParam)^.paramH = nHotKey then
        if Assigned(coFFHotKey.FOnHotKey) then coFFHotKey.FOnHotKey(coFFHotKey);
     end;
    end;
    Function TFFHotKey.OpenHotKey : Boolean;
    begin
      nHotKey := GetKeysInt(coFFHotKey.HotKey);
      if nHotKey=0 then begin
        Result := False;
        exit;
      end;
      hHook:=SetwindowsHookEx(WH_JOURNALRECORD, HookProc ,HInstance,0); //建立键盘鼠标操作消息纪录链
      Result := True;
    end;Procedure TFFHotKey.CloseHotKey;
    begin
      UnHookWindowsHookEx(hHook);
    end;
      

  2.   

    GetKeysInt是什么函数?我怎么在帮助里找不到,它是属于哪个库的?