tags:

views:

290

answers:

3

Is there a Win32 API way to get an enumeration of all the open windows? Seems like there must be just not sure where to start looking.

+3  A: 

EnumWindows() is for that. You call it and provide a callback. It invokes the callback for every found window and passes a handle to that window.

You can then use the handle to query the window parameters and decide whether it is of interest for you or do some action with it.

sharptooth
guess i should have guessed *that* name. thanks!
JustJeff
+2  A: 

Hi, have a look here:
How To Enumerate Windows Using the WIN32 API

Andre Kraemer
A: 

You'll want to use the EnumDesktopWindows function in user32.dll.

Here's some C# code to get you pointed to the correct API Calls. I'm not sure how this would look in C but you get the idea.

[DllImport("user32.dll")]
private static extern int EnumDesktopWindows(IntPtr hDesktop, EnumWindowsProc ewp, int lParam);
Nate Bross