分别应用了EnumWindows,GetClassName,GetWindowText三个API unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; lst1: TListBox; lbl1: TLabel; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; type TMyStruct = record hwnd: HWND; ClassName: string; FormTitle:string; end; TMyStructArray = array of TMyStruct; PMyStructArray = ^TMyStructArray; var Form1: TForm1; implementation {$R *.dfm} function EnumWindowsProc_4(hwnd: HWND; lParam: LPARAM): Boolean; stdcall; var buf: array[Byte] of Char; p: PMyStructArray; begin GetClassName(hwnd, buf, SizeOf(buf)); p := PMyStructArray(lParam); SetLength(p^, Length(p^) + 1); p^[High(p^)].hwnd := hwnd; p^[High(p^)].ClassName := buf; GetWindowText(hwnd, buf, SizeOf(buf)); p^[High(p^)].FormTitle := buf; Result := True; end; procedure TForm1.Button1Click(Sender: TObject); var Arr: TMyStructArray; i: Integer; begin EnumWindows(@EnumWindowsProc_4, Integer(@Arr)); lbl1.Caption := '窗口总数:' + IntToStr(Length(Arr))+' '; for i:=0 to Length(Arr) - 1 do lst1.Items.Add(IntToStr(i+1)+'-- Handle: '+IntToStr(Arr[i].hwnd)+'-- ClassName: '+Arr[i].ClassName+'-- FormTitle: '+Arr[i].FormTitle); end; end.