You can pass a user defined parameter in LPARAM so I'll leave the return of the window text to you.
In the EnumWindowProc or EnumChildProc you can pass your own type (AKA ProcessInfo_t)....
ProcessInfo_t * processInfo;
processInfo = reinterpret_cast<ProcessInfo_t*>(lParam);
In the header file of the C++ app add the following:
bool CBogusDlg::FindDesiredWindow(UINT state);
static BOOL WINAPI EnumWindowsProc(HWND hwnd, LPARAM lParam);
static BOOL WINAPI EnumChildProc(HWND hwnd, LPARAM lParam);
In the cpp file add:
bool CBogusDlg::FindDesiredWindow(UINT state)
{
int bogus;
// If a name wasn't supplied, don't bother.
EnumWindows(EnumWindowsProc, (LPARAM)(&bogus));
return false;
}
BOOL WINAPI CBogusDlg::EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
int bogus;
// char title[100];
EnumChildWindows(hwnd, EnumChildProc, (LPARAM)(&bogus));
// ::GetWindowText(hwnd, title, 100);
return 1;
}
BOOL WINAPI CBogusDlg::EnumChildProc(HWND hwnd, LPARAM lParam)
{
char title[100];
::GetWindowText(hwnd, title, 100);
TRACE("%s\n", title);
return 1;
}