Enumerate Windows
Post date: Mar 16, 2010 3:39:06 PM
In computing, a window is a visual area containing some kind of user interface. It usually has a rectangular shape.[1] It displays the output of and may allow input to one or more processes.
Read more: http://en.wikipedia.org/wiki/Window_%28computing%29
type
PMyEnumParam = ^TMyEnumParam;
TMyEnumParam = record
lb: TListbox;
end;
function GetWindows(const hWnd: Longword; Param: PMyEnumParam): LongBool;
stdcall;
var
Len: Longint;
S: string;
begin
Result := True;
if not (IsWindow(hWnd) and IsWindowVisible(hWnd)) then
Exit;
Len := SendMessage(hWnd, WM_GETTEXTLENGTH, 0, 0);
if Len > 0 then
begin
SetLength(S, Len);
SendMessage(hWnd, WM_GETTEXT, Len + 1, Longint(Pchar(S)));
Param.lb.Items.Add(s);
end;
// mit Result = False kann die Callbackfunktion vorzeitig verlassen werden
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Param: TMyEnumParam;
begin
Param.lb := Listbox1;
EnumWindows(@GetWindows, LPARAM(@Param));
end;