diff --git a/code/sys/sys_win32.c b/code/sys/sys_win32.c index 6dd00d07..e40caaa0 100644 --- a/code/sys/sys_win32.c +++ b/code/sys/sys_win32.c @@ -235,7 +235,36 @@ char* Sys_MicrosoftStorePath(void) #ifdef MSSTORE_PATH if (!microsoftStorePath[0]) { - Q_strcat(microsoftStorePath, MAX_OSPATH, "C:\\Program Files\\ModifiableWindowsApps\\Quake 3\\EN"); + TCHAR szPath[MAX_PATH]; + FARPROC qSHGetFolderPath; + HMODULE shfolder = LoadLibrary("shfolder.dll"); + + if(shfolder == NULL) + { + Com_Printf("Unable to load SHFolder.dll\n"); + return microsoftStorePath; + } + + qSHGetFolderPath = GetProcAddress(shfolder, "SHGetFolderPathA"); + if(qSHGetFolderPath == NULL) + { + Com_Printf("Unable to find SHGetFolderPath in SHFolder.dll\n"); + FreeLibrary(shfolder); + return microsoftStorePath; + } + + if( !SUCCEEDED( qSHGetFolderPath( NULL, CSIDL_PROGRAM_FILES, + NULL, 0, szPath ) ) ) + { + Com_Printf("Unable to detect CSIDL_PROGRAM_FILES\n"); + FreeLibrary(shfolder); + return microsoftStorePath; + } + + FreeLibrary(shfolder); + + // default: C:\Program Files\ModifiableWindowsApps\Quake 3\EN + Com_sprintf(microsoftStorePath, sizeof(microsoftStorePath), "%s%cModifiableWindowsApps%c%s%cEN", szPath, PATH_SEP, PATH_SEP, MSSTORE_PATH, PATH_SEP); } #endif return microsoftStorePath;