How to get list of open windows

Hi, I want to get list of all open windows. I'm sure that many people have done it before. Can somebody point me to a right example?

I'm working on Windows XP SP3 and gcc compiler.

Thanks in anticipation.
Shannon.
Use EnumWindows function:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <windows.h>
using namespace std;

BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pCmdLine, int iCmdShow)
{
	EnumWindows(EnumWindowsProc, NULL);

	return 0;
}

BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{

	char class_name[80];
	char title[80];
	GetClassName(hwnd,class_name, sizeof(class_name));
	GetWindowText(hwnd,title,sizeof(title));
    cout <<"Window title: "<<title<<endl;
    cout <<"Class name: "<<class_name<<endl<<endl;


	return TRUE;
}

http://msdn.microsoft.com/en-us/library/ms633497(VS.85).aspx
Thanks Null, your pointer is right. I got the required list.

Shannon.
Topic archived. No new replies allowed.