2 * (c) The University of Glasgow 2002
7 #include "HsDirectory.h"
10 * Function: __hscore_getFolderPath()
12 * Late-bound version of SHGetFolderPath(), coping with OS versions
13 * that have shell32's lacking that particular API.
16 #if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32)
17 typedef HRESULT (*HSCORE_GETAPPFOLDERFUNTY)(HWND,int,HANDLE,DWORD,char*);
19 __hscore_getFolderPath(HWND hwndOwner,
25 static int loaded_dll = 0;
26 static HMODULE hMod = (HMODULE)NULL;
27 static HSCORE_GETAPPFOLDERFUNTY funcPtr = NULL;
28 /* The DLLs to try loading entry point from */
29 char* dlls[] = { "shell32.dll", "shfolder.dll" };
33 } else if (loaded_dll == 0) {
35 for(i=0;i < sizeof(dlls); i++) {
36 hMod = LoadLibrary(dlls[i]);
38 (funcPtr = (HSCORE_GETAPPFOLDERFUNTY)GetProcAddress(hMod, "SHGetFolderPathA")) ) {
43 if (loaded_dll == 0) {
48 /* OK, if we got this far the function has been bound */
49 return (int)funcPtr(hwndOwner,nFolder,hToken,dwFlags,pszPath);
50 /* ToDo: unload the DLL on shutdown? */