hook
//yanlei,yanleigis@21cn.com
var
Form1: TForm1;
hHook: integer;
Timesnum: integer;
implementation
{$R *.DFM}
const
Timescount = 300;
function HookProc(iCode: integer;
wParam: wParam;
lParam: lParam): LResult;
stdcall;
begin
Timesnum := 0;
Result := 0;
end;
function StartHook: Boolean;
begin
Result := False;
if hHook = 0 then
begin
hHook := SetWindowsHookEx(WH_JOURNALRECORD, HookProc, HInstance, 0);
if hHook > 0 then
begin
Result := True;
end;
end;
end;
procedure StopHook;
begin
if hHOok > 0 then
begin
UnHookWindowsHookEx(hHook);
hHook := 0;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
hHook := 0;
StartHook();
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
inc(Timesnum);
label1.Caption := floattostr(Timesnum);
if Timesnum > Timescount then
ShowMessage('ok');
end;
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
stophook;
end;