Checking program path C++, Win32

Started by
3 comments, last by Turold 16 years, 8 months ago
How can I get a full path to my main exe file using Win32 and C++?
Advertisement
You can use GetModuleFileName() with a HMODULE of 0.
This function in VS2005 is superseded by GetModuleFileNameW, which returns wide chars. How can I use the orignal, with normal chars? If I can't, how can I easily convert wide chars to c chars?
Either go to your project settings, under general and change the character set from Unicode to multi-byte, explicitly use GetModuleFileNameA or you can use wcstombs() to translate wide characters to narrow characters. (Or if you feel like the C++ method, the narrow() member function of the ctype locale facet.)
Wow, man! You impress me. You seem to know every little technical detail. So many ways to solve one little problem. Big thx :)

This topic is closed to new replies.

Advertisement