Improve setting Microsoft Store path

Respect configured Program Files directory and use MSSTORE_PATH for
the directory name.
This commit is contained in:
Zack Middleton 2021-11-06 20:43:03 -04:00
parent d1d5a89aad
commit fe7325be29

View file

@ -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;