resolve SHGetFolderPath dynamicly since it is not available on all Windows

systems.
This commit is contained in:
Alexander Gottwald 2005-01-31 10:32:19 +00:00
parent 8ac3be3f6c
commit 2982d173ca
2 changed files with 38 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2005-01-31 Alexander Gottwald <ago at freedesktop dot org>
* InitOutput.c:
resolve SHGetFolderPath dynamicly since it is not available on all Windows
systems.
2005-01-12 Alexander Gottwald <ago at freedesktop dot org>
* winmsg.c

View File

@ -43,6 +43,13 @@ from The Open Group.
#endif
#ifdef RELOCATE_PROJECTROOT
#include <shlobj.h>
typedef HRESULT (*SHGETFOLDERPATHPROC)(
HWND hwndOwner,
int nFolder,
HANDLE hToken,
DWORD dwFlags,
LPTSTR pszPath
);
#endif
@ -627,11 +634,34 @@ winFixupPaths (void)
}
if (getenv("HOME") == NULL)
{
HMODULE shfolder;
SHGETFOLDERPATHPROC shgetfolderpath = NULL;
char buffer[MAX_PATH + 5];
strncpy(buffer, "HOME=", 5);
if(SHGetFolderPath(NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, NULL, 0,
buffer + 5) == 0)
/* Try to load SHGetFolderPath from shfolder.dll and shell32.dll */
shfolder = LoadLibrary("shfolder.dll");
/* fallback to shell32.dll */
if (shfolder == NULL)
shfolder = LoadLibrary("shell32.dll");
/* resolve SHGetFolderPath */
if (shfolder != NULL)
shgetfolderpath = (SHGETFOLDERPATHPROC)GetProcAddress(shfolder, "SHGetFolderPathA");
/* query appdata directory */
if (shgetfolderpath &&
shgetfolderpath(NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, NULL, 0,
buffer + 5) == 0)
{
putenv(buffer);
} else
{
winMsg (X_ERROR, "Can not determine HOME directory\n");
}
if (shfolder != NULL)
FreeLibrary(shfolder);
}
if (!g_fLogFileChanged) {
static char buffer[MAX_PATH];