R
ruder
Unregistered / Unconfirmed
GUEST, unregistred user!
俺按网上的范例编写了个全局键盘钩子的dll<br>然后这样调用这个dll<br>program Project1;<br><br>uses<br> Windows,<br> Messages,<br> SysUtils,<br> Variants,<br> Classes,<br> Graphics,<br> Controls,<br> Forms,<br> Dialogs;<br>var<br>function EnablekeyboardHook(hh:integer):bool;external 'Project2.dll';<br>function disablehook:bool;external 'Project2.dll';<br><br>procedure doit;<br>var<br>s1,s2:string;<br>hhandle1,hhandle2:Thandle;<br>b1,b2:bool;<br>begin<br>s1:='1.txt - 记事本';<br>s2:='2.txt - 记事本';<br>hhandle1:=findwindow(nil,pchar(s1));<br>hhandle2:=findwindow(nil,pchar(s2));<br>if (hhandle1>0) and (hhandle2>0) then begin<br> showmessage('handle ok');<br> b1:=EnablekeyboardHook(GetWindowThreadProcessId(hhandle1));<br> if b1 then showmessage('1 ok');<br> sleep(4000); <br> b2:=EnablekeyboardHook(GetWindowThreadProcessId(hhandle2));<br> if b2 then showmessage('2 ok');<br> end;<br>end;<br><br>begin<br>doit;<br>end.<br>运行后第一个已经成功挂接,但第二个却没有。<br>不知为何,盼高手解答,分数不多(我没有分了),thanks!