P
poy
Unregistered / Unconfirmed
GUEST, unregistred user!
我需要做一个hook的dll ,用于捕捉Desktop的重画事件。如以下HookWord代码 ,事先我先取得desktop的 handle 存在 hDesktop中。在捕捉到消息后,判断是否为desktop的重画事件,如果是就向宿主窗口,发送消息 : postmessage(fCallerHwnd,$0401,0,5);在宿 主窗口有有处理 $0401的消息函数,可是怎么也没起作用,于是向另一个进程的另一窗口发送一消息 postmessage(1573644,100,0,5); 再次执行,这个窗口有消息处理过程执行,而宿主窗口 依旧没有,真是晕死我了,困扰我两天了,各位请帮个忙。<br><br><br>library HookWord;<br>uses<br> SysUtils,Messages,Windows, Classes, Dialogs;<br>type<br> PMyMSG =^tagMyMSG;<br> tagMyMSG =record<br> hwnd :Cardinal;<br> msgCode:UInt;<br> wParam :LongInt;<br> lParam :LongInt;<br> time Word;<br> pt :TPoint;<br> end;<br>var<br> fCallerHwnd:HWND;<br> aHooK:HHook ;<br><br>function GetMsgProcHook(Code:Integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;<br>var<br> pmHWND WORD;<br> hDesktop WORD;<br>begin<br><br> hDesktop:=65698 ;<br> pmHWND:=PMyMsg(lparam).hwnd ;<br> if pmHWND =hDesktop then<br> begin<br> if (PMyMSG(lparam).msgCode = WM_PAINT) then<br> begin<br> postmessage(1573644,100,0,5);<br> postmessage(fCallerHwnd,$0401,0,5);<br> end;<br><br> end;<br> Result:=CallNextHookEx(aHooK,code,Wparam,lParam);<br><br>end;<br><br>procedure HookON(aHwnd:HWND);stdcall;<br>begin<br> aHooK :=SetWindowsHookEx(WH_GETMESSAGE ,@GetMsgProcHook,HInstance, 0);<br> fCallerHwnd:=aHwnd;<br>end;<br><br>procedure UnHook;stdcall;<br>begin<br> UnHookWindowsHookEx(aHook);<br>end;<br><br>{$R *.res}<br>exports<br> HookON,unHook ;<br>begin<br>end.