mirror of
https://github.com/isledecomp/LEGOIslandRebuilder.git
synced 2025-02-18 09:00:15 -05:00
cmn: use LoadLibrary for shell32 in case it hasn't been loaded already
This commit is contained in:
parent
88cb3c0c23
commit
51494e96b6
1 changed files with 5 additions and 11 deletions
16
cmn/path.cpp
16
cmn/path.cpp
|
@ -32,17 +32,12 @@ BOOL RecursivelyCreateDirectory(LPCTSTR directory)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef UNICODE
|
#ifdef UNICODE
|
||||||
typedef BOOL (WINAPI *SHGetSpecialFolderPathSignature)(HWND hwndOwner, LPWSTR lpszPath, int nFolder, BOOL fCreate);
|
typedef BOOL (WINAPI *SHGetSpecialFolderPath_t)(HWND hwndOwner, LPWSTR lpszPath, int nFolder, BOOL fCreate);
|
||||||
#else
|
#else
|
||||||
typedef BOOL (WINAPI *SHGetSpecialFolderPathSignature)(HWND hwndOwner, LPSTR lpszPath, int nFolder, BOOL fCreate);
|
typedef BOOL (WINAPI *SHGetSpecialFolderPath_t)(HWND hwndOwner, LPSTR lpszPath, int nFolder, BOOL fCreate);
|
||||||
#endif
|
#endif
|
||||||
BOOL GetAppDataPath(LPTSTR s)
|
BOOL GetAppDataPath(LPTSTR s)
|
||||||
{
|
{
|
||||||
OSVERSIONINFO info;
|
|
||||||
ZeroMemory(&info, sizeof(info));
|
|
||||||
info.dwOSVersionInfoSize = sizeof(info);
|
|
||||||
GetVersionEx(&info);
|
|
||||||
|
|
||||||
// Dynamically link to SHGetSpecialFolderPath because not all versions of Windows have it
|
// Dynamically link to SHGetSpecialFolderPath because not all versions of Windows have it
|
||||||
#ifdef UNICODE
|
#ifdef UNICODE
|
||||||
LPCSTR functionName = "SHGetSpecialFolderPathW";
|
LPCSTR functionName = "SHGetSpecialFolderPathW";
|
||||||
|
@ -50,11 +45,11 @@ BOOL GetAppDataPath(LPTSTR s)
|
||||||
LPCSTR functionName = "SHGetSpecialFolderPathA";
|
LPCSTR functionName = "SHGetSpecialFolderPathA";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SHGetSpecialFolderPathSignature GetSpecialFolderPath = (SHGetSpecialFolderPathSignature)GetProcAddress(GetModuleHandle(_T("SHELL32.DLL")), functionName);
|
SHGetSpecialFolderPath_t getSpecialFolderPath = (SHGetSpecialFolderPath_t)GetProcAddress(LoadLibrary(_T("SHELL32.DLL")), functionName);
|
||||||
BOOL haveDir = FALSE;
|
BOOL haveDir = FALSE;
|
||||||
BOOL usedShell = FALSE;
|
BOOL usedShell = FALSE;
|
||||||
if (GetSpecialFolderPath) {
|
if (getSpecialFolderPath) {
|
||||||
haveDir = GetSpecialFolderPath(NULL, s, CSIDL_APPDATA, TRUE);
|
haveDir = getSpecialFolderPath(NULL, s, CSIDL_APPDATA, TRUE);
|
||||||
usedShell = TRUE;
|
usedShell = TRUE;
|
||||||
} else {
|
} else {
|
||||||
// Assume we're on Windows 95 which has no application data folder, we bodge it to write to
|
// Assume we're on Windows 95 which has no application data folder, we bodge it to write to
|
||||||
|
@ -64,7 +59,6 @@ BOOL GetAppDataPath(LPTSTR s)
|
||||||
haveDir = TRUE;
|
haveDir = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//MessageBox(0, s, usedShell ? _T("Using API") : _T("Is this Windows 95?"), 0);
|
|
||||||
return haveDir;
|
return haveDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue