Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Collect all active window class names

Many programs (True Transparancy and others) can get all active or running in background window class names like this one:

Delphi 7 Object Inspector name is tpropertyinspector
Opera main window class name is operawindowclass
etc.

So how to get any opened window class name in Delphi?

like image 613
Little Helper Avatar asked Dec 16 '22 10:12

Little Helper


2 Answers

Call EnumWindows to get all the top level windows. Then call GetClassName to find out the window class name for each window. If you also wish to probe child windows then call EnumChildWindows on each top level window.

Call GetClassName like this:

var
  ClassName: string;
  len: Integer;
...
SetLength(ClassName, 256);
len := GetClassName(window, PChar(ClassName), Length(ClassName));
if len=0 then
  RaiseLastOSError;
SetLength(ClassName, len);
like image 75
David Heffernan Avatar answered Dec 28 '22 11:12

David Heffernan


Simply use the GetClassName function in the Windows API (same way in Delphi as in any language).

like image 30
Andreas Rejbrand Avatar answered Dec 28 '22 09:12

Andreas Rejbrand