Win32: Set current directory at startup to where the exe is.

Fixes the "out-of-the-box" experience in MSVC.
This commit is contained in:
Henrik Rydgard 2013-08-26 20:48:34 +02:00
parent 85270d5898
commit af1ae8fde7

View File

@ -62,6 +62,17 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
{
Common::EnableCrashingOnCrashes();
wchar_t modulePath[MAX_PATH];
GetModuleFileName(NULL, modulePath, MAX_PATH);
for (int i = wcslen(modulePath) - 1; i > 0; i--) {
if (modulePath[i] == '\\') {
modulePath[i] = 0;
break;
}
}
SetCurrentDirectory(modulePath);
// GetCurrentDirectory(MAX_PATH, modulePath); // for checking in the debugger
bool hideLog = true;
#ifdef _DEBUG