I wrote the following code one year ago to return a list of all the current windows
#include <iostream>
#include <windows.h>
using namespace std;
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
TCHAR buffer[512];
SendMessage(hwnd, WM_GETTEXT, 512, (LPARAM)(void*)buffer);
cout << buffer << endl;
return TRUE;
}
int main()
{
EnumWindows(EnumWindowsProc, NULL);
return 0;
}
This code worked when i originally wrote it, however now the result list I am getting is not what I expected.
I am getting the following text repeated around 40 times.
...
0031F6F0
0031F6F0
0031F6F0
0031F6F0
0031F6F0
0031F6F0
0031F6F0
...
How can I change the 0031F6F0 to read each window name instead of the above, and also why would the code result have changed?