You can enumerate all the windows using the API
BOOL WINAPI EnumWindows(
__in WNDENUMPROC lpEnumFunc,
__in LPARAM lParam
);
The above function will callback
BOOL CALLBACK EnumWindowsProc(
__in HWND hwnd,
__in LPARAM lParam
);
function for each Window with all the necessary information that you can use.
You can also use
EnumDesktopWindows
API