不行呀 <br>Unit Unit1;<br><br>Interface<br><br>Uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls, TLHelp32;<br><br>Type<br> TProcessInfo = Record<br> ExeFile: String;<br> ProcessID: DWORD;<br> End;<br> pProcessInfo = ^TProcessInfo;<br>Type<br> TForm1 = Class(TForm)<br> Button1: TButton;<br> ListBox1: TListBox;<br> Button2: TButton;<br> Button3: TButton;<br> Button4: TButton;<br> Button5: TButton;<br> Button6: TButton;<br> Procedure Button1Click(Sender: TObject);<br> Procedure FormCreate(Sender: TObject);<br> Procedure FormDestroy(Sender: TObject);<br> Procedure Button2Click(Sender: TObject);<br> Procedure Button3Click(Sender: TObject);<br> Procedure Button4Click(Sender: TObject);<br> Procedure Button5Click(Sender: TObject);<br> Procedure Button6Click(Sender: TObject);<br> Private<br> function GetAllF(h: HWnd): boolean;<br> { Private declarations }<br> Public<br> { Public declarations }<br> End;<br><br>Var<br> Form1: TForm1;<br> l: Tlist; ////返回的东东在"L"这个TList中。<br><br>Implementation<br><br>Procedure TForm1.Button1Click(Sender: TObject);<br>Var<br> lppe: TProcessEntry32;<br> found: boolean;<br> Hand: THandle;<br>Begin<br> Hand := CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);<br> found := Process32First(Hand, lppe);<br> While found Do<br> Begin<br> //ListBox1.Items.Add(StrPas(lppe.szExeFile)); //列出所有进程。<br> If StrPas(lppe.szExeFile) = 'delphi32.exe' Then<br> begin<br> // OpenProcess(<br> //EnumChildWindows(<br> GetAllF(Hand);<br>// EnumThreadWindows(OpenProcess(PROCESS_TERMINATE,false,lppe.th32ProcessID), @EnumProc, Integer(ListBox1.Items));<br> exit;<br> end;<br> found := Process32Next(Hand, lppe);<br> End;<br>End;<br>function TForm1.GetAllF(h:HWnd):boolean ;<br>Var<br> hCurrentWindow: HWnd;<br> szText: Array[0..254] Of char;<br>Begin<br> listbox1.clear;<br> hCurrentWindow :=GetWindow(Handle, GW_HWNDFIRST);<br> While hCurrentWindow &lt;&gt; 0 Do<br> Begin<br> If GetWindowText(hCurrentWindow, @szText, 255) &gt; 0 Then<br> begin<br> if GetWindowThreadProcessId(hCurrentWindow)=h then<br> ListBox1.Items.Add(Strpas(@szText));<br> end;<br> hCurrentWindow := GetWindow(hCurrentWindow, GW_HWNDNEXT);<br> End;<br>End;