大家好!
        我想先禁止键盘按键,然后在解除这一禁止请问怎么做???????????

解决方案 »

  1.   

    哦,哪儿呢~你小子耍我啊,哪儿有牛鬼蛇神。看我扁你。
    // 引自超级猛料   禁止鼠标或键盘工作  类 别:系统控制
    function FunctionDetect (LibName, FuncName: String; var LibPointer: Pointer): boolean;
    var
      LibHandle:tHandle;
    begin
      Result := false;
      LibPointer := NIL;
        if LoadLibrary(PChar(LibName)) = 0 then exit;
        LibHandle := GetModuleHandle(PChar(LibName));
        if LibHandle <> 0 then
        begin
          LibPointer := GetProcAddress(LibHandle, PChar(FuncName));
          if LibPointer <> NIL then Result := true;
        end;
    end;
    procedure TForm1.Button1Click(Sender: TObject);
    var
      xBlockInput : function (Block: BOOL): BOOL; stdcall;
    begin
      if FunctionDetect ('USER32.DLL', 'BlockInput', @xBlockInput) then
      begin
        xBlockInput (True);  // 禁止键盘鼠标
        Sleep(10000);       // 等待10秒
        xBlockInput (False); // 允许键盘鼠标
      end;
    end;