[
]5555。。。<br>贴了90%的贴子,被一个非法操作就给over了。<br>那就再写一遍吧。<br>问题基本搞定,不一定要用dialgobox,关键是要现实的窗体的parnet必须要设成<br>游戏的窗体。这样就可以弹出自己的窗体,而游戏的窗体也不会最小化了。<br>我写了一个,w2k+delphi6+q3a测试通过。<br>代码比较乱,注意看注释。<br>热键是左边的win建加小键盘上得*建<br>ps,别忘了给分。[
]<br>//--------------App part start----------------<br>//form上放两个button.<br>//Copyright by tt.t(ttui) @2k+3.1.19@bit<br><br>unit test;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, <br><br>Dialogs,<br> StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> Button2: TButton;<br> procedure Button1Click(Sender: TObject);<br> procedure Button2Click(Sender: TObject);<br> procedure FormDestroy(Sender: TObject);<br> procedure FormCreate(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br>function sethook:bool;external 'ptdll.dll';<br>function endhook:bool;external 'ptdll.dll';<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>//if<br> sethook;<br> // then showmessage('Hook Successful');<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br>//if<br>endhook;<br>// then showmessage('Unhook Successful!!');<br>end;<br><br>procedure TForm1.FormDestroy(Sender: TObject);<br>begin<br>//endhook;<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br>//sethook;<br>end;<br><br>end.<br>//--------------App part end------------------<br><br>//--------------DLL part start------------------<br>//--------------library project------------------<br>library ptdll;<br><br>uses<br> SysUtils,<br> Classes,<br> Windows,<br> Messages,<br> dll_vol in 'dll_vol.pas',<br> dia in 'dia.pas' {Form1};<br><br>{$R *.RES}<br><br>exports sethook,endhook;<br>begin<br>hNextHookProc := 0;<br>procSaveExit := ExitProc;<br>ExitProc := @HotKeyHookExit;<br>end.<br>//-------------------dll_vol unit-----------------------<br>unit dll_vol;<br><br>interface<br><br>uses Windows,Messages,Dialogs,Sysutils,dia;<br><br>var<br> hNextHookProc: HHook;<br> procSaveExit: Pointer;<br><br> function sethook:bool;export;<br> function hookproc(iCode:Integer;wParam: WPARAM;lParam: LPARAM): <br><br>LRESULT; stdcall;<br> function endhook:bool;export;<br> procedure HotKeyHookExit;far;<br><br>implementation<br><br>function HookProc(iCode: integer; wParam: wParam; lParam: lParam): <br><br>LResult; stdcall;<br>var<br> hwnd:dword;<br> AppRect:TRect;<br> title
char;<br>// dc:hdc;<br>begin<br> result:=0;<br> if iCode<0 then<br> begin<br> CallNextHookEx(hnexthookproc,iCode,wParam,lParam);<br> result:=0;<br> Exit;<br> end;<br>{<br> dc:=getdc(0);<br> textout(dc,20,20,pchar(inttohex(wparam,3)),3);<br> releasedc(0,dc);<br>}<br> if ((lParam and $80000000)=0) and<br> (GetKeyState(VK_LWIN)<0) and (wParam=$6a) then<br> begin<br> Messagebeep(0);<br> hwnd:=getforegroundwindow;<br> try<br> GetMem(title,255);<br> getwindowtext(hwnd,title,255);<br> if title<>'_Msg_Dx_' then<br> begin<br> try<br> form1:=TForm1.CreateParented(hwnd);<br> GetWindowRect(hwnd,AppRect);<br> form1.Left:=(AppRect.Right-AppRect.Left) div 2;<br> form1.Top:=(AppRect.Bottom-AppRect.Top) div 2;<br> form1.Caption:='_Msg_Dx_';<br> form1.ShowModal;<br> finally<br> form1.Free;<br> end;<br> end;<br> finally<br> FreeMem(title);<br> end;<br> result:=1;<br> end;<br>end;<br><br>function sethook:bool;export;<br>begin<br> result:=false;<br> if hnexthookproc<>0 then exit;<br> hNextHookProc := SetWindowsHookEx(WH_KEYBOARD,hookproc,HInstance,0);<br> Result := hNextHookProc <> 0;<br>end;<br><br>procedure hotkeyhookexit;<br>begin<br> if hNextHookProc <> 0 then endHook;<br> ExitProc := procSaveExit;<br>end;<br><br>function endhook:bool;export;<br>begin<br> if hNextHookProc <> 0 then<br> begin<br> UnhookWindowshookEx(hNextHookProc); // 解除 Keyboard Hook<br> hNextHookProc := 0;<br> end;<br> Result := hNextHookProc = 0;<br>end;<br><br>end.<br>//----------------dia unit-------------------<br>//注意!!form的borderstyle必须设成bsdialog!!<br>unit dia;<br><br>interface<br><br>uses<br> Windows, Messages, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>end.<br><br>//--------------DLL part end------------------<br>