Reputation: 2561
I am trying to load the name of an image using its VM address by calling GetModuleFileName()
which seems to return the value correctly into a TCHAR[]
array. I am able to display the data correctly using MessageBox()
but cout <<
seems to display some funky hexadecimal number.
TCHAR buf[MAX_PATH];
HMODULE hProc = LoadLibrary(TEXT("kernel32.dll"));
GetModuleFileName(hProc, buf, MAX_PATH);
cout << buf; //Produces the odd number
MessageBox(NULL, buf, NULL, MB_OK); //Produces correct filepath
FreeLibrary(hProc);
Am I supposed to set a flag for cout
so it knows to print it correctly? Thank you!
Upvotes: 0
Views: 150
Reputation: 143249
Probably you need to use wcout
, because your TCHAR
might be unicodish. Or convert it.
Upvotes: 5