Little Helper
Little Helper

Reputation: 2456

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?

Upvotes: 4

Views: 4416

Answers (2)

David Heffernan
David Heffernan

Reputation: 613382

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);

Upvotes: 10

Andreas Rejbrand
Andreas Rejbrand

Reputation: 109003

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

Upvotes: 3

Related Questions