扑捉别的程序的消息的钩子问题(100分)

  • 主题发起人 主题发起人 爱提
  • 开始时间 开始时间

爱提

Unregistered / Unconfirmed
GUEST, unregistred user!
function KeyboardHookHandler(iCode:Integer;WParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;export;<br>begin<br>&nbsp; &nbsp; &nbsp;Result :=0;<br>&nbsp; &nbsp;if iCode &lt;0 then<br>&nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp;Result :=CallNextHookEx(hNextHookProc,iCode,wParam,lParam);<br>&nbsp; &nbsp; &nbsp; &nbsp;Exit;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp;if wParam=40004 then<br>&nbsp; &nbsp; &nbsp; showmessage('stop');<br>end;<br><br>这些是我设计的一个钩子函数,请问我那个地方错了。<br>我要扑捉消息队列中id为40004的一个消息,就是超级解霸发出的‘step’消息<br>
 
if wParam=40004 then<br>&nbsp; &nbsp; &nbsp; 好象不是这样的吧!!
 
????<br>
 
use WH_GETMESSAGE <br>PMSG(lParam).message=40004 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 
这样好象不行啊<br><br>o*o 能详细点吗?谢谢!!1
 
因为你说的是消息队列,所以建议use WH_GETMESSAGE .<br>但有可能消息直接发送到窗口,这要用WH_CALLWNDPROC,if PCWPSTRUCT(lParam).message=40004 then<br>同时还要判断窗口句柄是超级解霸的.<br><br><br>
 
试一下:if wParam.result=40004 then
 
function KeyboardHookHandler(iCode:Integer;WParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;export;<br>begin<br>&nbsp; &nbsp; &nbsp;Result :=0;<br>&nbsp; &nbsp;if iCode &lt;0 then<br>&nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp;Result :=CallNextHookEx(hNextHookProc,iCode,wParam,lParam);<br>&nbsp; &nbsp; &nbsp; &nbsp;Exit;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp;if wParam=40004 then<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; Result := 1;<br>&nbsp; &nbsp; &nbsp; showmessage('stop');<br>&nbsp; end;<br>end;<br>
 
多人接受答案了。
 
后退
顶部