如果不考虑子窗口,可用EnumWindows()枚举
#include <stdio.h>
#include <windows.h>
BOOL CALLBACK EnumFunc(HWND hWnd, LPARAM lParam)
{
if (IsWindowVisible(hWnd))
{
char wText[1024], wClass[1024];
GetWindowText(hWnd, wText, sizeof(wText));
GetClassName(hWnd, wClass, sizeof(wClass));
printf("窗口句柄:%d,窗口标题:%s,窗口类名:%s\n", hWnd, wText, wClass);
}
return 1;
}
main()
{
EnumWindows(EnumFunc, 0);
}