H
hikehilter
Unregistered / Unconfirmed
GUEST, unregistred user!
我想通过CBTPROC来捕捉系统的创建事件。但每次打开一个窗口,都会有很多生成的句柄出来,
我想只关闭最上面的父窗体,但这个过程好像有问题,一运行就死,那位给点主意,这个函数
是在我的DLL里面的 。
//CBTProc process Function.
function CBT_HookProc(nCode: Integer; WPARAM: wParam; LPARAM: lParam): LResult; stdcall;
var
TempHwnd:integer;
begin
if nCode =HCBT_CREATEWND then begin
if rHookRec^.MainWindow <> 0 then
begin
SendMessage(rHookRec^.MainWindow, MSG_CBT, WPARAM,LParam);
TempHwnd:=wParam;
While GetParent(TempHwnd)>0 do
TempHwnd:=GetParent(TempHwnd);
if Getparent(TempHwnd)<>rHookRec^.MainWindow then
begin
Result:=1;
Exit;
end else
result := CallNextHookEx(rHookRec^.HookID, nCode, wParam, lParam);
end;
end;
end;
我想只关闭最上面的父窗体,但这个过程好像有问题,一运行就死,那位给点主意,这个函数
是在我的DLL里面的 。
//CBTProc process Function.
function CBT_HookProc(nCode: Integer; WPARAM: wParam; LPARAM: lParam): LResult; stdcall;
var
TempHwnd:integer;
begin
if nCode =HCBT_CREATEWND then begin
if rHookRec^.MainWindow <> 0 then
begin
SendMessage(rHookRec^.MainWindow, MSG_CBT, WPARAM,LParam);
TempHwnd:=wParam;
While GetParent(TempHwnd)>0 do
TempHwnd:=GetParent(TempHwnd);
if Getparent(TempHwnd)<>rHookRec^.MainWindow then
begin
Result:=1;
Exit;
end else
result := CallNextHookEx(rHookRec^.HookID, nCode, wParam, lParam);
end;
end;
end;