diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-04-22 11:53:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-22 11:53:09 +0200 |
commit | b4860ce3ac81ae5df1661eefb22a1adf01676957 (patch) | |
tree | 65c0e06b2cc6ea5a21d796af452402df2537a746 /platform | |
parent | 3610b4fd770ff34102d0502f4d0fa9d036c7ecd9 (diff) | |
parent | 3d908f57d8c8b6a72ee38cefca7628dc5a3ddc6b (diff) |
Merge pull request #28166 from KLee1248/first_bug
Use SHGetKnownFolderPath instead of SHGetFolderPathW
Diffstat (limited to 'platform')
-rw-r--r-- | platform/windows/os_windows.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 1a5050a15a..5e12106639 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -2870,39 +2870,41 @@ String OS_Windows::get_godot_dir_name() const { String OS_Windows::get_system_dir(SystemDir p_dir) const { - int id; + KNOWNFOLDERID id; switch (p_dir) { case SYSTEM_DIR_DESKTOP: { - id = CSIDL_DESKTOPDIRECTORY; + id = FOLDERID_Desktop; } break; case SYSTEM_DIR_DCIM: { - id = CSIDL_MYPICTURES; + id = FOLDERID_Pictures; } break; case SYSTEM_DIR_DOCUMENTS: { - id = CSIDL_PERSONAL; + id = FOLDERID_Documents; } break; case SYSTEM_DIR_DOWNLOADS: { - id = 0x000C; + id = FOLDERID_Downloads; } break; case SYSTEM_DIR_MOVIES: { - id = CSIDL_MYVIDEO; + id = FOLDERID_Videos; } break; case SYSTEM_DIR_MUSIC: { - id = CSIDL_MYMUSIC; + id = FOLDERID_Music; } break; case SYSTEM_DIR_PICTURES: { - id = CSIDL_MYPICTURES; + id = FOLDERID_Pictures; } break; case SYSTEM_DIR_RINGTONES: { - id = CSIDL_MYMUSIC; + id = FOLDERID_Music; } break; } - WCHAR szPath[MAX_PATH]; - HRESULT res = SHGetFolderPathW(NULL, id, NULL, 0, szPath); + PWSTR szPath; + HRESULT res = SHGetKnownFolderPath(id, 0, NULL, &szPath); ERR_FAIL_COND_V(res != S_OK, String()); - return String(szPath); + String path = String(szPath); + CoTaskMemFree(szPath); + return path; } String OS_Windows::get_user_data_dir() const { |