Created
December 16, 2011 11:45
-
-
Save yoggy/1485763 to your computer and use it in GitHub Desktop.
get exe filename using GetModuleFileName()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::string get_exe_filename() | |
{ | |
char full_path[MAX_PATH]; | |
char drive[MAX_PATH]; | |
char dir[MAX_PATH]; | |
char filename[MAX_PATH]; | |
char ext[MAX_PATH]; | |
char exe_filename[MAX_PATH]; | |
::GetModuleFileName(NULL, full_path, MAX_PATH); | |
::_splitpath_s( | |
full_path, | |
drive, | |
MAX_PATH, | |
dir, | |
MAX_PATH, | |
filename, | |
MAX_PATH, | |
ext, | |
MAX_PATH); | |
::_makepath_s(exe_filename, MAX_PATH, NULL, NULL, filename, ext); | |
return std::string(exe_filename); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment