请问如何得到QQ登陆窗口的句柄和登陆窗口所属的线程ID? ( 积分: 100 )

  • 主题发起人 主题发起人 chengang_1981
  • 开始时间 开始时间
C

chengang_1981

Unregistered / Unconfirmed
GUEST, unregistred user!
如题,请各位大虾帮帮忙,小弟谢先拉!!!!!!!!!
 
如题,请各位大虾帮帮忙,小弟谢先拉!!!!!!!!!
 
upupupupupupupupupupupupupupupupup
 
是个问题,我也想知道。关注中……
 
小弟正在做一个QQ密码输入的记录小软件,关于键盘钩子那部分已经完成,,现在就是要知道QQ登陆窗口的句柄和它所属的线程ID才能用钩子对它进行监视,请教各位大虾这部分应该怎么做? &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;谢谢!!!!!
 
高手,你快出来,我已经不能等待,你快出来,生命因你而精彩。
 
QQ2004II的类名和标题是,其它没试,不过取标题的方法大同小异:<br>ClassName : #32770<br>Title(11个字符): #32#32#13#10#32#13#32#13#10#10#013<br>这样获得句柄:<br>QQwnd := Findwindow('#32770',#32#32#13#10#32#13#32#13#10#10#013);<br><br>无非是用:<br>WM_GETTEXTLENGTH和WM_GETTEXT
 
好像标题会动态变化,不过都是这几个字符: #32、#13、#10,也可以根据特征性的东西判断:<br>function EnumWindowsProc(Wnd: HWND; Param: Integer): Boolean; stdcall;<br>var<br> cn : Array[0..255] of char;<br> tab : HWND;<br> tId : DWORD;<br>begin<br> &nbsp;Result := TRUE;<br> &nbsp;if GetClassName(wnd, cn, 255) &gt; 0 then<br> &nbsp; if cn = '#32770' then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; //判断是不是QQ登录窗口,下面的条件可以自己补充修改<br> &nbsp; &nbsp; if (FindWindowEx(wnd, 0, 'SysTabControl32','Tab1') &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; &nbsp; &nbsp;(FindWindowEx(wnd, 0, 'Button','申请号码') &lt;&gt; 0) <br> &nbsp; &nbsp; begin<br> &nbsp; &nbsp; &nbsp;tID := GetWindowThreadProcessID(wnd, nil);<br> &nbsp; &nbsp; &nbsp;Form1.Memo1.Lines.Add('QQ登录对话框句柄:'+IntToStr(Wnd));<br> &nbsp; &nbsp; &nbsp;Form1.Memo1.Lines.Add('QQ登录对话框线程ID:' + IntToSTr(tID));<br> &nbsp; &nbsp; end;<br> &nbsp; end;<br>end;<br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> EnumWindows(@EnumWindowsProc,0);<br>end;<br>不过即便有了窗口句柄,要取密码也不是随随便便的事情。这些都是入门级的技术,如果是用这样的技术去做坏事是很丢人的,呵呵
 
to &nbsp;YuZi<br>大虾你的方法可行,我想在向你请教一个问题,,就是你是怎么确定QQ登录窗口的类名是<br>#32770? &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 谢谢
 
偶也想知道为什么是 #32770,<br>还有就是一般的窗口,这个值怎么确定。。<br>等待ing...........................
 
已经全部完成,结帐。
 
我把我检测QQ登陆窗口类名及子窗口的代码贴出来,与大家分享。(检测时只打开登陆窗口,不要登陆进出。)<br><br><br>unit Unit1;<br><br>interface<br><br>uses<br> &nbsp;Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> &nbsp;Dialogs, StdCtrls, shellapi, Tlhelp32;<br><br>type<br> &nbsp;TForm1 = class(TForm)<br> &nbsp; &nbsp;Button1: TButton;<br> &nbsp; &nbsp;ListBox1: TListBox;<br> &nbsp; &nbsp;Label1: TLabel;<br> &nbsp; &nbsp;procedure Button1Click(Sender: TObject);<br> &nbsp;private<br> &nbsp; &nbsp;{ Private declarations }<br> &nbsp;public<br> &nbsp; &nbsp;{ Public declarations }<br> &nbsp;end;<br><br>var<br> &nbsp;Form1: TForm1;<br><br>implementation<br>var<br>processid,i,j:dword;<br>{$R *.dfm}<br><br>function EnumWindowsProcd(Wnd: HWND; Param: Integer): Boolean; stdcall;<br>var<br> cn : Array[0..255] of char;<br>begin<br>Result := TRUE;<br>j:=j+1;<br>Form1.ListBox1.Items.Add('===================');<br>Form1.ListBox1.Items.Add('子窗口'+inttostr(j)+'---&gt;&gt;&gt;');<br>GetClassName(wnd, cn, 255);<br>Form1.ListBox1.Items.Add('子窗口类名:'+cn);<br>Getwindowtext(wnd, cn, 255);<br>Form1.ListBox1.Items.Add('子窗口文本名:'+cn);<br>end;<br><br>function EnumWindowsProc(Wnd: HWND; Param: Integer): Boolean; stdcall;<br>var<br> cn : Array[0..255] of char;<br> hprocessId : DWORD;<br>begin<br>Result := TRUE;<br>GetWindowThreadProcessID(wnd,hprocessId);<br>if &nbsp;hprocessId=processId then<br>begin<br>i:=i+1;<br>j:=0;<br>Form1.ListBox1.Items.Add(' &nbsp; &nbsp;');<br>Form1.ListBox1.Items.Add('窗口'+inttostr(i)+'----------------------&gt;&gt;&gt;&gt;&gt;&gt;');<br>GetClassName(wnd, cn, 255);<br>Form1.ListBox1.Items.Add('窗口句柄:'+inttostr(Wnd));<br>Form1.ListBox1.Items.Add('窗口类名:'+cn);<br>Getwindowtext(wnd, cn, 255);<br>Form1.ListBox1.Items.Add('窗口文本:'+cn);<br>Form1.ListBox1.Items.Add('显示本窗口所有子窗口:');<br>EnumchildWindows(Wnd,@EnumWindowsProcd,0);<br>Form1.ListBox1.Items.Add('=====================');<br>Form1.ListBox1.Items.Add('子窗口结束');<br>end;<br>end;<br><br><br><br><br><br><br><br><br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>ContinueLoop: BOOL;<br>FSnapshotHandle: THandle;<br>FProcessEntry32: TProcessEntry32;<br>begin<br>i:=0;<br>FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);<br>FProcessEntry32.dwSize := SizeOf(FProcessEntry32);<br>ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);<br>while Integer(ContinueLoop) &lt;&gt; 0 do<br>begin<br>if (UpperCase(ExtractFileName(FProcessEntry32.szExeFile))=UpperCase('QQ.exe')) or (UpperCase(FProcessEntry32.szExeFile)=UpperCase('QQ.exe')) then<br>begin<br>processid :=FProcessEntry32.th32ProcessID;<br>break;<br>end;<br>ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);<br>end;<br>CloseHandle(FSnapshotHandle);<br>ListBox1.Clear;<br>Form1.ListBox1.Items.Add('显示属于QQ进程的所有窗口:');<br>EnumWindows(@EnumWindowsProc,0);<br>end;<br><br><br>end.
 
还有一个问题:能不能通过进程中的QQ.exe找到这个窗口的句柄,记得以前好象有过。
 
这好象不行吧,只能通过QQ进程来查找。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
788
import
I
后退
顶部