Maybe you'll find this example useful.
#include <windows.h>
#include <stdio.h>
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) {
printf("HWND: %u\n", hwnd);
char className[256];
if (GetClassName(hwnd, className, sizeof className) == 0)
fprintf(stderr, "GetClassName failed.\n");
else
printf("Class Name: %s\n", className);
char windowText[256]; // text in the window's title bar
if (GetWindowText(hwnd, windowText, sizeof windowText) == 0)
fprintf(stderr, "GetWindowText failed.\n");
else
printf("Window Text: %s\n", windowText);
putchar('\n');
return TRUE;
}
int main() {
BOOL ret = EnumDesktopWindows(
NULL, // Desktop to enumerate (NULL is default)
EnumWindowsProc, // Callback function
0); // lParam value to callback function
if (ret == 0) fprintf(stderr, "EnumDesktopWindows failed.\n");
return 0;
}