Source Code



Disable Keyboard and Mouse

  • anonymous
  • Dec 14' 13
  • Delphi
  • 254
  • 103
  • United States

simple code to manage disability keyboard and mouse

 

function FuncAvail (VLibraryname, VFunctionname: string; var VPointer: pointer):
 boolean;
var 
  Vlib: tHandle;
begin
  Result := false;
  VPointer := NIL;
   if LoadLibrary(PChar(VLibraryname)) = 0 then 
      exit;
   VPointer := GetModuleHandle(PChar(VLibraryname));
   if Vlib  0 then
   begin
    VPointer := GetProcAddress(Vlib, PChar(VFunctionname));
    if VPointer  NIL then 
       Result := true;
   end;
end;

// Source code in Button1 on Form1 - 

procedure TForm1.Button1Click(Sender: TObject);
var
   xBlockInput : function(Block: BOOL): BOOL; stdcall;
begin
  if FuncAvail("USER32.DLL", "BlockInput", @xBlockInput) then
  begin
   xBlockInput(true);
   Sleep(15000);  // 15 secounds
   xBlockInput(false);
  end;
end;
  • Tags : keyboard, mouse, disable
comments powered by Disqus



Category