WIN32: Use SHGetFolderPath to get the location of the Application Data folder (#1449)
This commit is contained in:
parent
9725716f26
commit
1de8f1e529
4 changed files with 38 additions and 80 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue