library Lib1;
uses WinTypes, Messages, WinProcs, Toolhelp;
const
WM_NOTIFY = WM_USER + $100;
var
targetHWnd: HWnd;
function HookProc(wID: Word; dwData: LongInt): Bool; export;
begin
PostMessage(targetHWnd, WM_NOTIFY, wID, dwData);
Result := False
end;
procedure InstallHook(notifyWindow: HWnd); export;
begin
if targetHWnd = 0 then
begin
if not NotifyRegister(0, HookProc, NF_NORMAL) then
begin
MessageBox(notifyWindow, 'Неудача NotifyRegister!',
'Ошибка!', MB_OK + MB_ICONSTOP);
end
else
begin
targetHWnd := notifyWindow;
end;
end;
end;
procedure UnInstallHook; export;
begin
if targetHWnd <> 0 then
begin
NotifyUnregister(0);
targetHWnd := 0;
end;
end;
exports
InstallHook,
UnInstallHook;
begin
targetHWnd := 0;
end.
|