From 6d8b742b9cc904d2cec8c84c927dd7ff81fabc8f Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 11 Jan 2007 20:15:48 +0000 Subject: [PATCH] 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. 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 | 7 ++++++- bacula/src/win32/compat/winapi.c | 18 ++++++++++++++++++ bacula/src/win32/winapi.h | 6 +++++- bacula/technotes-2.0 | 2 ++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/bacula/src/lib/parse_conf.c b/bacula/src/lib/parse_conf.c index ecce0a4cfd..1e432a640e 100755 --- a/bacula/src/lib/parse_conf.c +++ b/bacula/src/lib/parse_conf.c @@ -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)); diff --git a/bacula/src/win32/compat/winapi.c b/bacula/src/win32/compat/winapi.c index 0de12dc822..55ea083788 100644 --- a/bacula/src/win32/compat/winapi.c +++ b/bacula/src/win32/compat/winapi.c @@ -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); } diff --git a/bacula/src/win32/winapi.h b/bacula/src/win32/winapi.h index 3af4fa46a0..94497023a8 100644 --- a/bacula/src/win32/winapi.h +++ b/bacula/src/win32/winapi.h @@ -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 */ diff --git a/bacula/technotes-2.0 b/bacula/technotes-2.0 index 9c7a506979..6ac62eda69 100644 --- a/bacula/technotes-2.0 +++ b/bacula/technotes-2.0 @@ -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 -- 2.39.5