看看合适否。<br><br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> ListBox1: TListBox;<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br> function EnumWndProc(AWnd:HWND;AlParam:LPARAM):Boolean;stdcall;<br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>function EnumWndProc(AWnd: HWND; AlParam: LPARAM):Boolean;stdcall;<br>var<br> WndCaption: array[0..254] of Char;<br>begin<br> if IsWindowVisible(AWnd) then<br> begin<br> GetWindowText(AWnd, @WndCaption, 254);<br><br> if WndCaption[0]<>chr(0) then<br> Form1.ListBox1.Items.Add(Format('%d = %s',[AWnd,StrPas(WndCaption)]));<br> end;<br><br> Result := True;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> EnumWindows(@EnumWndProc,0);<br>end;<br><br>end.