-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkey.dpr
47 lines (37 loc) · 850 Bytes
/
key.dpr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
library Key;
uses
WinTypes,
WinProcs,
Messages;
const
KeyEvent = WM_USER + 1;
var
HookHandle : hHook;
function KeyHook(nCode: integer; WParam: Word; LParam: LongInt): Longint; stdcall;
var LogWindowHandle: THandle;
begin
if (nCode = HC_ACTION) then begin
LogWindowHandle := FindWindow('TKeyForm', nil);
if LogWindowHandle <> 0 then
SendMessage(LogWindowHandle, KeyEvent, wParam, lParam);
end;
Result := CallNextHookEx(HookHandle, nCode, WParam, LParam);
end;
procedure SetKeyHook; stdcall;
begin
if HookHandle <> 0 then exit;
HookHandle := SetWindowsHookEx(WH_KEYBOARD, @KeyHook, HInstance, 0);
end;
procedure DelKeyHook; stdcall;
begin
if HookHandle <> 0 then begin
UnhookWindowsHookEx(HookHandle);
HookHandle := 0;
end;
end;
exports
SetKeyHook,
DelKeyHook;
begin
HookHandle := 0;
end.