1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68:
| unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TForm1 = class(TForm) Button2: TButton; ListBox1: TListBox; procedure Button2Click(Sender: TObject); private public end; type TFensterInfo=record Handle: HWND; Caption: String; end; var Form1: TForm1; FensterInfo: array of TFensterInfo; lengthvar: integer = 0; implementation {$R *.dfm} Function EnumWindowsProc(Wnd: HWND): BOOL; stdcall; var Capt: Array [0..128] of Char; begin Result:=true; 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 SendMessage(Wnd, WM_GETTEXT, Sizeof(Capt), integer(@Capt)); SetLength(FensterInfo, length(FensterInfo)+1); inc(lengthvar); FensterInfo[High(FensterInfo)].Caption:=Capt; FensterInfo[High(FensterInfo)].Handle:=Wnd; end; end; procedure TForm1.Button2Click(Sender: TObject); var i: integer; begin lengthvar := 0; SetLength(FensterInfo, 0); EnumWindows(@EnumWindowsProc, 0); Form1.ListBox1.Items.Clear; for i := 0 to lengthvar do begin Form1.ListBox1.Items.Add(FensterInfo[i].Caption); end end; end. |