From 934e7b9372447663a09475fd6ceaccffe7e0f668 Mon Sep 17 00:00:00 2001 From: "J.Ingram" <26800139+GirianSeed@users.noreply.github.com> Date: Sun, 27 Jul 2025 12:20:56 -0400 Subject: [PATCH] Call SHGetFolderPathA directly Removing shfolder.h satisfies MSVC, and calling the function directly makes PFNSHGETFOLDERPATHA unnecessary. --- Makefile | 2 +- code/sys/sys_win32.c | 41 ++--------------------------------------- 2 files changed, 3 insertions(+), 40 deletions(-) diff --git a/Makefile b/Makefile index efafbe55..4e1d2ab0 100644 --- a/Makefile +++ b/Makefile @@ -668,7 +668,7 @@ ifdef MINGW $(call bin_path, $(TOOLS_MINGW_PREFIX)-gcc)))) endif - LIBS= -lws2_32 -lwinmm -lpsapi + LIBS= -lws2_32 -lwinmm -lpsapi -lshell32 AUTOUPDATER_LIBS += -lwininet # clang 3.4 doesn't support this diff --git a/code/sys/sys_win32.c b/code/sys/sys_win32.c index 28f9ef34..e740bcd6 100644 --- a/code/sys/sys_win32.c +++ b/code/sys/sys_win32.c @@ -38,7 +38,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include -#include #include #include #include @@ -104,30 +103,14 @@ Sys_DefaultHomePath char *Sys_DefaultHomePath( void ) { TCHAR szPath[MAX_PATH]; - PFNSHGETFOLDERPATHA qSHGetFolderPath; - HMODULE shfolder = LoadLibrary("shfolder.dll"); - - if(shfolder == NULL) - { - Com_Printf("Unable to load SHFolder.dll\n"); - return NULL; - } if(!*homePath && com_homepath) { - qSHGetFolderPath = (PFNSHGETFOLDERPATHA)GetProcAddress(shfolder, "SHGetFolderPathA"); - if(qSHGetFolderPath == NULL) - { - Com_Printf("Unable to find SHGetFolderPath in SHFolder.dll\n"); - FreeLibrary(shfolder); - return NULL; - } - if( !SUCCEEDED( qSHGetFolderPath( NULL, CSIDL_APPDATA, + if( !SUCCEEDED( SHGetFolderPathA( NULL, CSIDL_APPDATA, NULL, 0, szPath ) ) ) { Com_Printf("Unable to detect CSIDL_APPDATA\n"); - FreeLibrary(shfolder); return NULL; } @@ -139,7 +122,6 @@ char *Sys_DefaultHomePath( void ) Q_strcat(homePath, sizeof(homePath), HOMEPATH_NAME_WIN); } - FreeLibrary(shfolder); return homePath; } @@ -240,33 +222,14 @@ char* Sys_MicrosoftStorePath(void) if (!microsoftStorePath[0]) { TCHAR szPath[MAX_PATH]; - PFNSHGETFOLDERPATHA qSHGetFolderPath; - HMODULE shfolder = LoadLibrary("shfolder.dll"); - if(shfolder == NULL) - { - Com_Printf("Unable to load SHFolder.dll\n"); - return microsoftStorePath; - } - - qSHGetFolderPath = (PFNSHGETFOLDERPATHA)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, + if( !SUCCEEDED( SHGetFolderPathA( 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); }