user145586
user145586

Reputation: 1097

GetModuleFileNameEx - Is it possible to get the path in char* and NOT in TCHAR[]?

Here is my code:

TCHAR szProcessName[MAX_PATH] = TEXT("<unknown>");
GetModuleFileNameEx (hProcess, NULL, szProcessName, 
                     sizeof(szProcessName)/sizeof(TCHAR));

I need the path in char*, and not in TCHAR[]. Is it somehow possible without converting (WideCharToMultiByte)?

Thanks...

Upvotes: 1

Views: 3020

Answers (2)

Paul Mitchell
Paul Mitchell

Reputation: 3281

Note that if you're not building a Unicode application (i.e., _UNICODE is not defined), then TCHAR == char

Upvotes: 0

Kirill V. Lyadvinsky
Kirill V. Lyadvinsky

Reputation: 99555

GetModuleFileNameEx is just a macro. You could use GetModuleFileNameExA for ANSI version. It will call GetModuleFileNameExW and then internally make all conversions.

But you should make sure that module filename does not contain Unicode characters.

char szProcessName[MAX_PATH] = "<unknown>";
GetModuleFileNameExA(hProcess, NULL, szProcessName, sizeof szProcessName);

Upvotes: 6

Related Questions