EnumWindows
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
function EnumWindowsFunc(Handle: THandle; List: TStrings):boolean; stdcall;
var
caption: array[0..256] of Char;
begin
if GetWindowText(Handle, Caption, SizeOf(Caption)-1) <> 0 then
begin
List.Add(Caption) ;
//List.Add(IntToStr(Handle));
end;
result :=True;
end;
procedure TMainForm.Button1Click(Sender: TObject);
begin
Memo1.Clear;
ListBox1.Clear;
EnumWindows(@EnumWindowsFunc, LParam(Memo1.Lines));
EnumWindows(@EnumWindowsFunc, LParam(ListBox1.Items));
end;