Skip to main content
gamedev.net
🔒 Locked

Checking program path C++, Win32

Started by Turold Aug 1, 2007 at 1:15 PM 3 replies 1k views
Original Post
Turold
Turold
How can I get a full path to my main exe file using Win32 and C++?
SiCrane
SiCrane
You can use GetModuleFileName() with a HMODULE of 0.
Turold
Turold
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?
SiCrane
SiCrane
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.)
Turold
Turold
Wow, man! You impress me. You seem to know every little technical detail. So many ways to solve one little problem. Big thx :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.