Mega Code Archive

 
Categories / Delphi / System
 

Listing all windows

Title: Listing all windows Question: I want to list all windows, including the invisible ones. How can this be performed? Answer: This simple little procedure uses the EnumWindows API function, and lists them in the listbox. Code: function EnumWindowsCode(Wnd : hWnd;Form : TMainFrm) : Boolean; Export; StdCall; var Buffer : Array[0..99] of char; begin GetWindowText(Wnd,Buffer,100); if StrLen(Buffer) 0 then Form.WindowList.Items.Add(StrPas(Buffer)); Result := True; end; It should be called like this: EnumWindows(@EnumWindowsCode,LongInt(Self)); This has been tested in delphi 4 on windows 98, but should work great with other versions of delphi and also with 95/NT4/W2K.