]> git.sur5r.net Git - bacula/bacula/commitdiff
kes Add dynamic dll entry point for SHGetFolderPath to Win32 code.
authorKern Sibbald <kern@sibbald.com>
Thu, 11 Jan 2007 20:15:48 +0000 (20:15 +0000)
committerKern Sibbald <kern@sibbald.com>
Thu, 11 Jan 2007 20:15:48 +0000 (20:15 +0000)
     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

bacula/src/lib/parse_conf.c
bacula/src/win32/compat/winapi.c
bacula/src/win32/winapi.h
bacula/technotes-2.0

index ecce0a4cfdd1c04846e0ec5375e4450f5abbb934..1e432a640efe04f3d3e880b109b7ee73cc5f9648 100755 (executable)
@@ -932,8 +932,13 @@ const char *get_default_configdir()
    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));
index 0de12dc822cacb470db4544bd7e7de9ce5889760..55ea0837887bc432045168c7390ca5847dd6e670 100644 (file)
@@ -85,6 +85,8 @@ t_GetCurrentDirectoryW  p_GetCurrentDirectoryW = NULL;
 t_GetVolumePathNameW    p_GetVolumePathNameW = NULL;
 t_GetVolumeNameForVolumeMountPointW p_GetVolumeNameForVolumeMountPointW = NULL;
 
+t_SHGetFolderPath       p_SHGetFolderPath = NULL;
+
 void 
 InitWinAPIWrapper() 
 {
@@ -203,5 +205,21 @@ 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);
 }
index 3af4fa46a0265907a43eb2de4073437c425eee14..94497023a80082425d2b3e46370fa7f2b8cc976c 100644 (file)
@@ -75,7 +75,6 @@ extern DWORD DLL_IMP_EXP g_platform_id;
 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);
@@ -177,6 +176,11 @@ extern t_GetVolumeNameForVolumeMountPointW DLL_IMP_EXP p_GetVolumeNameForVolumeM
 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 */
index 9c7a50697967633ac3adae1cc6566985a712fcdd..6ac62eda69044cbcc789a467f4c7ffc4d711d2e0 100644 (file)
@@ -3,6 +3,8 @@
 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