unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
ihook:hhook;
implementation{$R *.dfm}
function snapproc(icode:integer;wparam:wparam;lparam:lparam):integer;stdcall;
begin
result:=0;
if icode<0 then
result:=callnexthookex(ihook,icode,wparam,lparam)
else
begin
if (icode= HC_action)and(wparam=PM_REMOVE)and(pmsg(lparam)^.message=wm_showwindow) then
begin
showmessage('');
end;
end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
ihook:=setwindowshookex(WH_getmessage,snapproc,hinstance,0);
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
unhookwindowshookex(ihook);
end;end.
===============================
另请问高手,哪些钩子程序必须要在dll中?wm_spoolerstatus用哪个钩子截获?
谢谢。
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
ihook:hhook;
implementation{$R *.dfm}
function snapproc(icode:integer;wparam:wparam;lparam:lparam):integer;stdcall;
begin
result:=0;
if icode<0 then
result:=callnexthookex(ihook,icode,wparam,lparam)
else
begin
if (icode= HC_action)and(wparam=PM_REMOVE)and(pmsg(lparam)^.message=wm_showwindow) then
begin
showmessage('');
end;
end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
ihook:=setwindowshookex(WH_getmessage,snapproc,hinstance,0);
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
unhookwindowshookex(ihook);
end;end.
===============================
另请问高手,哪些钩子程序必须要在dll中?wm_spoolerstatus用哪个钩子截获?
谢谢。
也就是说:
function snapproc(icode:integer;wparam:wparam;lparam:lparam):integer;stdcall;
这个函数一定要在一个DLL里