我把我检测QQ登陆窗口类名及子窗口的代码贴出来,与大家分享。(检测时只打开登陆窗口,不要登陆进出。)<br><br><br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls, shellapi, Tlhelp32;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> ListBox1: TListBox;<br> Label1: TLabel;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> 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)+'--->>>');<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 hprocessId=processId then<br>begin<br>i:=i+1;<br>j:=0;<br>Form1.ListBox1.Items.Add(' ');<br>Form1.ListBox1.Items.Add('窗口'+inttostr(i)+'---------------------->>>>>>');<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) <> 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.