This *should* fix bug #747.
kes  Modify winbacula.nsi to substitute with g bin_dir_cmd. Should fix
     bug #742.
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.0@3973 
91ce42f0-d328-0410-95d8-
f526ca767f89
 
    HRESULT hr;
    static char szConfigDir[MAX_PATH + 1] = { 0 };
 
+   if (!p_SHGetFolderPath) {
+      bstrncpy(szConfigDir, DEFAULT_CONFIGDIR, sizeof(szConfigDir));
+      return szConfigDir;
+   }
+
    if (szConfigDir[0] == '\0') {
-      hr = SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, 0, szConfigDir);
+      hr = p_SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, 0, szConfigDir);
 
       if (SUCCEEDED(hr)) {
          bstrncat(szConfigDir, "\\Bacula", sizeof(szConfigDir));
 
 t_GetVolumePathNameW    p_GetVolumePathNameW = NULL;
 t_GetVolumeNameForVolumeMountPointW p_GetVolumeNameForVolumeMountPointW = NULL;
 
+t_SHGetFolderPath       p_SHGetFolderPath = NULL;
+
 void 
 InitWinAPIWrapper() 
 {
       }
    }
 
+   /* First try in SHFOLDER for older systems */
+   hLib = LoadLibraryA("SHFOLDER.DLL");
+   if (hLib) {
+      p_SHGetFolderPath = (t_SHGetFolderPath)
+         GetProcAddress(hLib, "SHGetFolderPath");
+      FreeLibrary(hLib);
+   }
+
+   /* Now try Shell32.dll for newer systems */
+   hLib = LoadLibraryA("SHELL32.DLL");
+   if (hLib) {
+      p_SHGetFolderPath = (t_SHGetFolderPath)
+         GetProcAddress(hLib, "SHGetFolderPath");
+      FreeLibrary(hLib);
+   }
+
    atexit(Win32ConvCleanupCache);
 }
 
 extern DWORD DLL_IMP_EXP g_MinorVersion;
 
 /* In ADVAPI32.DLL */
-
 typedef BOOL (WINAPI * t_OpenProcessToken)(HANDLE, DWORD, PHANDLE);
 typedef BOOL (WINAPI * t_AdjustTokenPrivileges)(HANDLE, BOOL,
           PTOKEN_PRIVILEGES, DWORD, PTOKEN_PRIVILEGES, PDWORD);
 extern t_AttachConsole DLL_IMP_EXP p_AttachConsole;
 
 void InitWinAPIWrapper();
+
+/* In SHFolder.dll on older systems, and now Shell32.dll */
+typedef BOOL (WINAPI * t_SHGetFolderPath)(HWND, int, HANDLE, DWORD, LPTSTR);
+extern t_SHGetFolderPath  DLL_IMP_EXP p_SHGetFolderPath;
+
 #endif
 
 #endif /* __WINAPI_H */
 
 General:
 Version 2.0.1
 11Jan06
+kes  Add dynamic dll entry point for SHGetFolderPath to Win32 code.
+     This *should* fix bug #747.
 kes  Modify winbacula.nsi to substitute with g bin_dir_cmd. Should fix
      bug #742.
 09Jan06