diff options
author | Cameron Cawley | 2018-12-16 15:04:24 +0000 |
---|---|---|
committer | Filippos Karapetis | 2018-12-16 17:04:24 +0200 |
commit | 1de8f1e5293f4ea72c9926dc6a0bac42fd6f7113 (patch) | |
tree | d5ade46df0d2291482065e30da26893e632bf95f /backends/platform/sdl/win32/win32_wrapper.cpp | |
parent | 9725716f26911b15b3f00343bbd9e6ad9bea1e2a (diff) | |
download | scummvm-rg350-1de8f1e5293f4ea72c9926dc6a0bac42fd6f7113.tar.gz scummvm-rg350-1de8f1e5293f4ea72c9926dc6a0bac42fd6f7113.tar.bz2 scummvm-rg350-1de8f1e5293f4ea72c9926dc6a0bac42fd6f7113.zip |
WIN32: Use SHGetFolderPath to get the location of the Application Data folder (#1449)
Diffstat (limited to 'backends/platform/sdl/win32/win32_wrapper.cpp')
-rw-r--r-- | backends/platform/sdl/win32/win32_wrapper.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/backends/platform/sdl/win32/win32_wrapper.cpp b/backends/platform/sdl/win32/win32_wrapper.cpp index b61098ab9a..6ad0f725ed 100644 --- a/backends/platform/sdl/win32/win32_wrapper.cpp +++ b/backends/platform/sdl/win32/win32_wrapper.cpp @@ -24,10 +24,15 @@ // We need certain functions that are excluded by default #undef NONLS #include <windows.h> +#if defined(__GNUC__) && defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) +// required for SHGetSpecialFolderPath in shlobj.h +#define _WIN32_IE 0x400 +#endif +#include <shlobj.h> #include "backends/platform/sdl/win32/win32_wrapper.h" -// VerSetConditionMask and VerifyVersionInfo didn't appear until Windows 2000, +// VerSetConditionMask, VerifyVersionInfo and SHGetFolderPath didn't appear until Windows 2000, // so we need to check for them at runtime ULONGLONG VerSetConditionMaskFunc(ULONGLONG dwlConditionMask, DWORD dwTypeMask, BYTE dwConditionMask) { typedef ULONGLONG(WINAPI *VerSetConditionMaskFunction)(ULONGLONG conditionMask, DWORD typeMask, BYTE conditionOperator); @@ -49,6 +54,16 @@ BOOL VerifyVersionInfoFunc(LPOSVERSIONINFOEXA lpVersionInformation, DWORD dwType return verifyVersionInfo(lpVersionInformation, dwTypeMask, dwlConditionMask); } +HRESULT SHGetFolderPathFunc(HWND hwnd, int csidl, HANDLE hToken, DWORD dwFlags, LPSTR pszPath) { + typedef HRESULT (WINAPI *SHGetFolderPathFunc)(HWND hwnd, int csidl, HANDLE hToken, DWORD dwFlags, LPSTR pszPath); + + SHGetFolderPathFunc pSHGetFolderPath = (SHGetFolderPathFunc)GetProcAddress(GetModuleHandle(TEXT("shell32.dll")), "SHGetFolderPathA"); + if (pSHGetFolderPath) + return pSHGetFolderPath(hwnd, csidl, hToken, dwFlags, pszPath); + + return SHGetSpecialFolderPath(hwnd, pszPath, csidl & !CSIDL_FLAG_MASK, csidl & CSIDL_FLAG_CREATE) ? S_OK : E_NOTIMPL; +} + namespace Win32 { bool confirmWindowsVersion(int majorVersion, int minorVersion) { |