有没有人能说一下
HOOK函数
SetWindowsHookEx
各个参数的意思?看了MSDN,英文太差,没看懂..
HC_ACTION是什么意思??
GetCurrentThreadID又是什么意思,用来干吗?还有,为什么大部分Hook都需要DLL呢?
没有DLL不行么最近学习API和Hook.几乎没看一一张
《Delphi.下深入Windows核心编程》的代码的问题
都有问题要问,书上也讲的太不清楚了。
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
const
WM_TestMessage = WM_USER + 2000;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}
var
HookHandle: HHOOK;function TestHookProc(Code: Integer; WParam: Longint;Msg:Longint): Longint;stdcall;
begin
if (Code = HC_ACTION) then
if PMsg(Msg)^.Message = WM_TestMessage then
begin
showMessage('已经截获该消息');
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.Button1Click(Sender: TObject);
begin
PostMessage(self.Handle,WM_TestMessage,0,0);
end;end.谢谢大家回答拉
HOOK函数
SetWindowsHookEx
各个参数的意思?看了MSDN,英文太差,没看懂..
HC_ACTION是什么意思??
GetCurrentThreadID又是什么意思,用来干吗?还有,为什么大部分Hook都需要DLL呢?
没有DLL不行么最近学习API和Hook.几乎没看一一张
《Delphi.下深入Windows核心编程》的代码的问题
都有问题要问,书上也讲的太不清楚了。
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
const
WM_TestMessage = WM_USER + 2000;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}
var
HookHandle: HHOOK;function TestHookProc(Code: Integer; WParam: Longint;Msg:Longint): Longint;stdcall;
begin
if (Code = HC_ACTION) then
if PMsg(Msg)^.Message = WM_TestMessage then
begin
showMessage('已经截获该消息');
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.Button1Click(Sender: TObject);
begin
PostMessage(self.Handle,WM_TestMessage,0,0);
end;end.谢谢大家回答拉
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货