Disable mouse an keyboard in whole Windows  

Send By: Lord Trancos
Web : N.A.
Email: lordtrancos@softhome.net
Date: 25/08/00

Tip accessed 428 times

 


Only works in Win98 or Win2k...

The next code, disable the keyboard and mouse in whole Windows for 4 seconds:


 procedure TForm1.Button1Click(Sender: TObject);

   function FuncAvail(_dllname, _funcname: string; var _p: pointer): boolean;
   { Devuelve true si la funcion _funcname esta disponible en la DLL _dllname.
    Si es asi, almacena en _p la direccion de la función.}

   var _lib: tHandle;

   begin
     Result := false;
     _p := NIL;
     if LoadLibrary(PChar(_dllname)) = 0 then exit;
     _lib := GetModuleHandle(PChar(_dllname));
     if _lib <> 0 then
       begin
         _p := GetProcAddress(_lib, PChar(_funcname));
         if _p <> NIL then Result := true;
       end;
   end;


 var
   xBlockInput : function(Block: BOOL): BOOL; stdcall;

 begin
   if FuncAvail('USER32.DLL', 'BlockInput', @xBlockInput) = true then
     begin
       {Bloquear entradas/Disable input}
       xBlockInput(true);
       sleep(4000);
       {Desbloquear/Enable}
       xBlockInput(false);
     end;
 end;



Pressing Ctrl+Alt+Del the disabling effect is lost...