diff --git a/bin/WinLauncher/WinLauncher.exe b/bin/WinLauncher/WinLauncher.exe old mode 100755 new mode 100644 index a6e1abff02d4..410d8262ac53 Binary files a/bin/WinLauncher/WinLauncher.exe and b/bin/WinLauncher/WinLauncher.exe differ diff --git a/bin/WinLauncher/WinLauncher64.exe b/bin/WinLauncher/WinLauncher64.exe old mode 100755 new mode 100644 index 048195fe23eb..5de7a1151941 Binary files a/bin/WinLauncher/WinLauncher64.exe and b/bin/WinLauncher/WinLauncher64.exe differ diff --git a/native/WinLauncher/WinLauncher/WinLauncher.cpp b/native/WinLauncher/WinLauncher/WinLauncher.cpp index 847ba820e5e5..bb5ae2930308 100644 --- a/native/WinLauncher/WinLauncher/WinLauncher.cpp +++ b/native/WinLauncher/WinLauncher/WinLauncher.cpp @@ -1165,6 +1165,20 @@ std::wstring GetCurrentDirectoryAsString() return std::wstring(buffer.data(), sizeWithoutTerminatingZero); } +static void SetPathVariable(const wchar_t *varName, REFKNOWNFOLDERID rfId) +{ + wchar_t env_var_buffer[1]; + if (GetEnvironmentVariableW(varName, env_var_buffer, 1) == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND) + { + wchar_t *path = NULL; + if (SHGetKnownFolderPath(rfId, KF_FLAG_DONT_VERIFY, NULL, &path) == S_OK) + { + SetEnvironmentVariableW(varName, path); + CoTaskMemFree(path); + } + } +} + int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, @@ -1187,6 +1201,10 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, return 0; } + // ensures path variables are defined + SetPathVariable(L"APPDATA", FOLDERID_RoamingAppData); + SetPathVariable(L"LOCALAPPDATA", FOLDERID_LocalAppData); + //it's OK to return 0 here, because the control is transferred to the first instance int exitCode = CheckSingleInstance(); if (exitCode != -1) return exitCode; diff --git a/native/WinLauncher/WinLauncher/stdafx.h b/native/WinLauncher/WinLauncher/stdafx.h index 331c84157ff5..81709a970482 100644 --- a/native/WinLauncher/WinLauncher/stdafx.h +++ b/native/WinLauncher/WinLauncher/stdafx.h @@ -9,8 +9,10 @@ #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers // Windows Header Files: -#include +#include #include +#include +#include // C RunTime Header Files #include @@ -24,5 +26,3 @@ #include #include #include - -// TODO: reference additional headers your program requires here