From af1ae8fde7e4391cd5d77cb151b61b7e564a6aa7 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Mon, 26 Aug 2013 20:48:34 +0200 Subject: [PATCH] Win32: Set current directory at startup to where the exe is. Fixes the "out-of-the-box" experience in MSVC. --- Windows/main.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Windows/main.cpp b/Windows/main.cpp index d88d771898..f28ffa27f9 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -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