Listing all open windows
To list (get) all open windows, you must use EnumWindows API function. It uses a callback function, that receives 2 parameters: a Window handle and a Pointer.
You can use it with a code like this (this code lists all open windows, even invisible ones in a listbox):
function EnumWindowsProc(Wnd : HWnd;Form : TForm1) : Boolean; Export;
{$ifdef Win32} StdCall; {$endif}
var
Buffer : Array[0..99] of char;
begin
GetWindowText(Wnd,Buffer,100);
if StrLen(Buffer) <> 0 then
Form.ListBox1.Items.Add(StrPas(Buffer));
Result := True;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
EnumWindows(@EnumWindowsProc,LongInt(Self));
end;

0 Comments:
Post a Comment
<< Home