unit Unit4;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br><br>type<br> EnumWindowsProc=function(hwnd:Thandle; lP:LPARAM):boolean;stdcall;<br><br>type<br> TForm4 = class(TForm)<br> ListBox1: TListBox;<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> procedure ListBox1DblClick(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br> function EnumWin(hwnd:Thandle; lP:LPARAM):boolean;stdcall;<br><br>var<br> Form4: TForm4;<br><br>implementation<br><br>{$R *.DFM}<br><br>function EnumWin(hwnd:Thandle; lP:LPARAM):boolean;stdcall;<br>var<br> buffer:array[0..255] of Char;<br> list:TListBox;<br>begin<br> List:=TListBox(lp);<br> GetwindowText(hwnd,buffer,256);<br> if StrLen(buffer)>0 then<br> begin<br> list.Items.AddObject(buffer,Tobject(hwnd));<br> end;<br>end;<br><br>procedure TForm4.Button1Click(Sender: TObject);<br>var<br> pp:EnumWindowsProc;<br>begin<br> pp:=MakeProcInstance(@ENumWin,HInstance);<br> EnumWindows(@pp,lparam(Listbox1));<br> FreeProcInstance(@pp);<br>end;<br><br>end.<br>你看这段行不行,从前贴子里的