X
x44348428
Unregistered / Unconfirmed
GUEST, unregistred user!
请问为什么我的程序就只能是局部hook,不能全局。我写dll了,也建共享内存了。谢谢!<br>基本代码如下:<br>
<br>----------------------<br>挂钩代码:<br>
代码:
function MsgHookProc(xiCode: Integer;xwParam: WPARAM;xlParam: LPARAM): LRESULT; stdcall; <br>var <br> LMsgInfo: PMsgInfo; <br>begin <br> if xiCode < 0 then <br> Result:=CallNextHookEx(MsgHookHandle,xiCode,xwParam,xlParam) <br> else <br> if (xiCode = HC_ACTION) then <br> begin <br> if (PCWPRetStruct(xlParam)^.hwnd = pSharedMem^.HWndSpy) then <br> begin <br> //走不到这里。 <br> end; <br> Result:=CallNextHookEx(MsgHookHandle,xiCode,xwParam,xlParam); <br> end; <br>end;
代码:
function StartHook(AHSpyWnd,AHRevWnd: THandle;MessageID: Word): BOOL; stdcall;<br>begin<br> Result:=False;<br> if MsgHookHandle <> 0 then<br> Exit;<br> pSharedMem^.HWndSpy:=AHSpyWnd;<br> pSharedMem^.HRevWnd:=AHRevWnd;<br> //pSharedMem^.MessageID:=MessageID;<br> MsgHookHandle:=SetWindowsHookEx(WH_CALLWNDPROCRET,@MsgHookProc,HInstance,0);<br> Result:=MsgHookHandle<>0;<br>end;