So, jetzt habe ich mir mal nen kleinen hook gebaut, kriege auch alles
ohne Fehler gestartet, nur passiert nix.
mousehook.dll
Delphi-Quellcode:
library mousehook;
uses
SysUtils,
Classes,
Windows,
Messages,
Dialogs;
var
HookHandle: Cardinal = 0;
WindowHandle: Cardinal = 0;
{$R *.res}
function MouseHookProc(nCode:integer;wParam:WParam;lParam:LParam): LResult; stdcall;
begin
Result := CallNextHookEx(HookHandle,nCode,wParam,lParam);
case nCode < 0 of
true: exit;
false: begin
if GetAsynckeyState(vk_lbutton) <> 0 then
showmessage('Die linke taste wurde gedrückt');
end;
end;
end;
function InstallHook(Hwnd: Cardinal): Boolean; stdcall;
begin
result := false;
if HookHandle = 0 then begin
HookHandle := SetWindowsHookEx(WH_Mouse,@MouseHookProc,
hInstance, 0);
WindowHandle := hwnd;
Result := true;
end;
end;
function UninstallHook: Boolean; stdcall;
begin
Result := UnHookWindowsHookEx(HookHandle);
HookHandle := 0;
end;
exports
InstallHook,
UninstallHook;
end.
MainFrm.pas
Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
begin
lib := loadlibrary('keyhook.dll');
if lib <> Invalid_Handle_Value then begin
InstallHook := GetProcAddress(lib,'InstallHook');
UninstallHook := GetProcAddress(lib,'UninstallHook');
end else Close;
end;