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); // Disable Keyboard & mouse
Sleep(10000); // Wait for for 10 Secounds
xBlockInput (False); // Enable Keyboard & mouse
end;
end;
Skoro funkcja pochodzi z USER32.DLL to czy nie lepiej jest ją statycznie zlinkować. Przecież User32.dll jest (na ogół) wymagane by uruchomić nasz exe ??
Może sie mylę, ale chyba po wywołaniu LoadLibrary() powinno być FreeLibrary() (pomijając sytuację, gdzie ładowanie nie powiodło się, tzn. uchwyt = 0)?
I po co to, mogles dac wskazowke jak zablokowac inputy, chociaz i to nie jest nikomu potrzebne.
może sie komuś z początkujących przyda...
Każdy czasem coś szuka, a jak jest kod to łatwiej