Hello,
I am trying to get the properties of a Microsoft's Notepad.exe window. I have an instance of this application running when I execute the code below.
#include <iostream>
#include <windows.h>
using namespace std;
BOOL CALLBACK PropEnumProcEx(HWND hwnd, LPTSTR lpszString, HANDLE hData, ULONG_PTR dwData) {
cout << "Property Label: " << lpszString << "." << endl;
return true;
}
int main()
{
HWND hNote = FindWindow("Notepad", NULL);
cout << "Notepad's handle: " << hNote << endl;
EnumPropsEx(hNote, PropEnumProcEx, 0);
cout << "Done" << endl;
return 0;
}
The output is:
Notepad's handle: 0x7e0b7e
Property Label:
Then i receive a "properties.exe has encountered a problem and needs to close. We are sorry for the inconvenience." Windows error message.
{P.S. my program is called properties.exe}
If I don't have a reference to lpszString in the callback function then the code executes as expected through to the end. I suspect I am not using the pointer of the string correctly...?
If someone could shed some light that would be appreciated.
Thanks,