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