Created
December 12, 2012 20:38
-
-
Save bagobor/4271409 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
.... | |
<after all includes> | |
#ifdef _WIN32 || _WIN64 | |
#include <windows.h> | |
#endif | |
.... | |
main() { | |
.... | |
#ifdef _WIN32 || _WIN64 | |
TCHAR module_filename[MAX_PATH]; | |
DWORD len = GetModuleFileName(NULL, module_filename, MAX_PATH); | |
for (DWORD p = len; p != 0; --p) { | |
if (module_filename[p] == '\\') { | |
module_filename[p] = __TEXT('\0'); | |
break; | |
} | |
} | |
BOOL res = SetCurrentDirectory(module_filename); | |
#endif | |
... | |
<post init code here> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment