Home > database >  How to find number of windows with the same title bar or class?
How to find number of windows with the same title bar or class?

Time:01-06

I'm trying to get an integer value for the number of windows running with a specific windows class/title. Is there a function that can do that? I've tried FindWindow but it doesn't seem to go through ALL the windows.

An example of what I am trying to do would be finding the number of Windows a user has open with the "Visual Studio" class.

CodePudding user response:

EnumWindows

Enumerates all top-level windows on the screen by passing the handle to each window, in turn, to an application-defined callback function.

You can use GetClassName, GetWindowText to retrieve the name of the class and the text of the specified window's title bar respectively. See the ScreenCaptureforHWND example.
For the others, as @IInspectable said, use EnumChildWindows. But as far as Visual Studio is concerned, EnumWindows is enough.

  • Related