5,390
社区成员
发帖
与我相关
我的任务
分享
var
Form1: TForm1;
HookHandle:HHook;
implementation
{$R *.dfm}
function TestHookProc(Code:Integer;WParam:Longint;Msg:Longint):Longint;stdcall;
begin
if PMsg(Msg)^.Message = WM_KEYDOWN then
if PMsg(Msg)^.wParam = VK_ESCAPE then
begin
Showmessage('ESC Key Down!');
Form1.Close;
end;
Result:=CallNextHookEx(HookHandle,Code,WParam,Longint(@msg));
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
HookHandle:=SetWindowsHookEx(WH_GETMESSAGE,TestHookProc,0,GetCurrentThreadID);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
UnHookWindowsHookEx(HookHandle);
end;
end.