The code worked all along. Somehow I manage to get Visual C++ Express not hit the break point on the final return statement and it appeared to run for ever.
In the example code bellow EnumWindows enumerates infinitely. How can one make it stop after all windows has been enumerated.
#include <Windows.h>
BOOL CALLBACK EnumWindowsProc(HWND hWnd, long lParam) {
TCHAR buff[255];
if (IsWindowVisible(hWnd)) {
GetWindowText(hWnd, (LPWSTR) buff, 254);
printf("%S\n", buff);
}
return TRUE;
}
int _tmain(int argc, _TCHAR* argv[]) {
EnumWindows(EnumWindowsProc, 0);
return 0;
}