L
longjiang
Unregistered / Unconfirmed
GUEST, unregistred user!
问题如下:
我怎么捕获系统所有的消息啊!!代码如下:
function HookProc(iCode: integer; wParam: wParam; lParam: lParam): LResult; stdcall;
var
s:string;
begin
if (PEventMsg(lparam)^.message = BM_CLICK) then
begin
Form1.ListBox1.Items.Add('1');
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
hooktimes := 0;
hHook := 0;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
inc(hooktimes);
if hooktimes = 1 then
begin
hookkey := TimeToStr(now) + ' ';
hHook := SetWindowsHookEx(WH_CALLWNDPROC, HookProc, HInstance, 0);
MessageBox(0, '启动', '信息', MB_ICONINFORMATION + MB_OK);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
UnHookWindowsHookEx(hHook);
hHook := 0;
if hooktimes <> 0 then
begin
MessageBox(0, '监视关闭', '信息', MB_ICONINFORMATION + MB_OK);
end;
hooktimes := 0;
end;
procedure TForm1.ListBox1DblClick(Sender: TObject);
begin
listbox1.clear;
end;
procedure TForm1.btn1Click(Sender: TObject);
begin
SendMessage(btn2.Handle ,BM_CLICK ,0,0 );
end;
问题使用WH_CALLWNDPROC的时候好像机器会死掉
我怎么捕获系统所有的消息啊!!代码如下:
function HookProc(iCode: integer; wParam: wParam; lParam: lParam): LResult; stdcall;
var
s:string;
begin
if (PEventMsg(lparam)^.message = BM_CLICK) then
begin
Form1.ListBox1.Items.Add('1');
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
hooktimes := 0;
hHook := 0;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
inc(hooktimes);
if hooktimes = 1 then
begin
hookkey := TimeToStr(now) + ' ';
hHook := SetWindowsHookEx(WH_CALLWNDPROC, HookProc, HInstance, 0);
MessageBox(0, '启动', '信息', MB_ICONINFORMATION + MB_OK);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
UnHookWindowsHookEx(hHook);
hHook := 0;
if hooktimes <> 0 then
begin
MessageBox(0, '监视关闭', '信息', MB_ICONINFORMATION + MB_OK);
end;
hooktimes := 0;
end;
procedure TForm1.ListBox1DblClick(Sender: TObject);
begin
listbox1.clear;
end;
procedure TForm1.btn1Click(Sender: TObject);
begin
SendMessage(btn2.Handle ,BM_CLICK ,0,0 );
end;
问题使用WH_CALLWNDPROC的时候好像机器会死掉