unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 =
class(TForm)
ListBox1: TListBox;
procedure FormShow(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
type
TFensterInfo =
record
Handle: HWND;
Caption:
String;
Icon: HIcon;
end;
PFensterInfoList = ^TFensterInfoList;
TFensterInfoList =
Array Of TFensterInfo;
Var
WindowList: TFensterInfoList;
Function EnumWindowsProc(Wnd: HWND; lp: LPARAM): LongBool;
stdcall;
Const
coBufferSize = 2048;
Var
lList: PFensterInfoList;
lCaption:
String;
lCapLen: Integer;
Begin
Result := True;
lList := PFensterInfoList(lp);
If IsWindowVisible(Wnd)
and
((GetWindowLong(Wnd, GWL_HWNDPARENT)=0)
or
(HWND(GetWindowLong(Wnd, GWL_HWNDPARENT))=GetDesktopWindow))
and
((GetWindowLong(Wnd, GWL_EXSTYLE)
and WS_EX_TOOLWINDOW)=0)
then
begin
SetLength(lCaption, coBufferSize);
lCapLen := SendMessage(Wnd, WM_GETTEXT, coBufferSize, Integer(PChar(lCaption)));
SetLength(lCaption, lCapLen);
SetLength(lList^, Length(lList^)+1);
lList^[High(lList^)].Caption := lCaption;
lList^[High(lList^)].Handle := Wnd;
end;
end;
procedure Tasks();
Begin
SetLength(WindowList, 0);
EnumWindows(@EnumWindowsProc, Integer(@WindowList));
End;
procedure TForm1.FormShow(Sender: TObject);
Var
i: Integer;
begin
Tasks;
For i := Low(WindowList)
To High(WindowList)
Do
ListBox1.Items.Add(WindowList[i].Caption);
end;
end.