From: sof Date: Mon, 21 Mar 2005 18:04:49 +0000 (+0000) Subject: [project @ 2005-03-21 18:04:48 by sof] X-Git-Tag: Initial_conversion_from_CVS_complete~878 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=c6f9cbaa3bfdc411e3605ca21fc9d6a44463cc85;p=ghc-hetmet.git [project @ 2005-03-21 18:04:48 by sof] __hscore_getFolderPath(): Don't limit ourselves to shell32.dll, look up shfolder.dll too. Merge to STABLE. --- diff --git a/ghc/lib/compat/cbits/directory.c b/ghc/lib/compat/cbits/directory.c index cca7b2c..1479a25 100644 --- a/ghc/lib/compat/cbits/directory.c +++ b/ghc/lib/compat/cbits/directory.c @@ -67,26 +67,28 @@ __hscore_getFolderPath(HWND hwndOwner, static int loaded_dll = 0; static HMODULE hMod = (HMODULE)NULL; static HSCORE_GETAPPFOLDERFUNTY funcPtr = NULL; + /* The DLLs to try loading entry point from */ + char* dlls[] = { "shell32.dll", "shfolder.dll" }; if (loaded_dll < 0) { return (-1); } else if (loaded_dll == 0) { - hMod = LoadLibrary("shell32.dll"); - if (hMod == NULL) { - loaded_dll = (-1); - return (-1); - } else { - funcPtr = (HSCORE_GETAPPFOLDERFUNTY)GetProcAddress(hMod, "SHGetFolderPathA"); - if (!funcPtr) { - loaded_dll = (-1); - return (-1); - } else { + int i; + for(i=0;i < sizeof(dlls); i++) { + hMod = LoadLibrary(dlls[i]); + if ( hMod != NULL && + (funcPtr = (HSCORE_GETAPPFOLDERFUNTY)GetProcAddress(hMod, "SHGetFolderPathA")) ) { loaded_dll = 1; + break; } } + if (loaded_dll == 0) { + loaded_dll = (-1); + return (-1); + } } /* OK, if we got this far the function has been bound */ return (int)funcPtr(hwndOwner,nFolder,hToken,dwFlags,pszPath); - /* ToDo: unload the DLL? */ + /* ToDo: unload the DLL on shutdown? */ } #endif