Skip to content

Instantly share code, notes, and snippets.

@bagobor
Created December 12, 2012 20:38
Show Gist options
  • Save bagobor/4271409 to your computer and use it in GitHub Desktop.
Save bagobor/4271409 to your computer and use it in GitHub Desktop.
....
<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