uses
Windows;
...
function EnumWindowsProc(Wnd: HWnd; lParam: LPARAM): bool; stdcall;
var
Buffer: array[0..99] of char;
begin
GetWindowText(Wnd, Buffer, 100);
if StrLen(Buffer) <> 0 then
TForm1(lParam).ListBox1.Items.Add(StrPas(Buffer));
Result := True;
end;
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
EnumWindows(@EnumWindowsProc, LongInt(Self));
end;
Maybe a bit better EnumWindowsProc:
function EnumWindowsProc(Wnd: HWnd; lParam: LPARAM): Bool; stdcall;
var
S: WideString;
Len: LongInt;
begin
SetLength(s, 100);
Len := GetWindowTextW(Wnd, @S[1], Length(S));
if Len > 0 then
TForm1(lParam).ListBox1.Items.Add(UTF8Encode(S));
Result := True;
end;