[Bf-blender-cvs] [89e2a8f17aa] master: Windows: Replace deprecated SHGetFolderPathW

mano-wii noreply at git.blender.org
Fri Nov 1 18:23:40 CET 2019


Commit: 89e2a8f17aa11e1fbba31a1b1b21e918fbb27c9a
Author: mano-wii
Date:   Fri Nov 1 14:23:00 2019 -0300
Branches: master
https://developer.blender.org/rB89e2a8f17aa11e1fbba31a1b1b21e918fbb27c9a

Windows: Replace deprecated SHGetFolderPathW

No functional change.

Differential Revision: https://developer.blender.org/D6172

===================================================================

M	intern/ghost/intern/GHOST_DisplayManagerWin32.cpp
M	intern/ghost/intern/GHOST_SystemPathsWin32.cpp
M	intern/ghost/intern/GHOST_SystemPathsWin32.h
M	intern/ghost/intern/GHOST_TaskbarWin32.h

===================================================================

diff --git a/intern/ghost/intern/GHOST_DisplayManagerWin32.cpp b/intern/ghost/intern/GHOST_DisplayManagerWin32.cpp
index 3b28f055191..aabaffc7732 100644
--- a/intern/ghost/intern/GHOST_DisplayManagerWin32.cpp
+++ b/intern/ghost/intern/GHOST_DisplayManagerWin32.cpp
@@ -24,8 +24,6 @@
 #include "GHOST_DisplayManagerWin32.h"
 #include "GHOST_Debug.h"
 
-#undef _WIN32_WINNT
-#define _WIN32_WINNT 0x501  // require Windows XP or newer
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 
diff --git a/intern/ghost/intern/GHOST_SystemPathsWin32.cpp b/intern/ghost/intern/GHOST_SystemPathsWin32.cpp
index bdc403b947e..63a6b7224b5 100644
--- a/intern/ghost/intern/GHOST_SystemPathsWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemPathsWin32.cpp
@@ -39,15 +39,16 @@ GHOST_SystemPathsWin32::~GHOST_SystemPathsWin32()
 
 const GHOST_TUns8 *GHOST_SystemPathsWin32::getSystemDir(int, const char *versionstr) const
 {
-  static char knownpath[MAX_PATH * 3 + 128] = {
-      0}; /* 1 utf-16 might translante into 3 utf-8. 2 utf-16 translates into 4 utf-8*/
-  wchar_t knownpath_16[MAX_PATH];
+  /* 1 utf-16 might translante into 3 utf-8. 2 utf-16 translates into 4 utf-8*/
+  static char knownpath[MAX_PATH * 3 + 128] = {0};
+  PWSTR knownpath_16 = NULL;
 
-  HRESULT hResult = SHGetFolderPathW(
-      NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, knownpath_16);
+  HRESULT hResult = SHGetKnownFolderPath(
+      FOLDERID_ProgramData, KF_FLAG_DEFAULT, NULL, &knownpath_16);
 
   if (hResult == S_OK) {
     conv_utf_16_to_8(knownpath_16, knownpath, MAX_PATH * 3);
+    CoTaskMemFree(knownpath_16);
     strcat(knownpath, "\\Blender Foundation\\Blender\\");
     strcat(knownpath, versionstr);
     return (GHOST_TUns8 *)knownpath;
@@ -59,12 +60,14 @@ const GHOST_TUns8 *GHOST_SystemPathsWin32::getSystemDir(int, const char *version
 const GHOST_TUns8 *GHOST_SystemPathsWin32::getUserDir(int, const char *versionstr) const
 {
   static char knownpath[MAX_PATH * 3 + 128] = {0};
-  wchar_t knownpath_16[MAX_PATH];
+  PWSTR knownpath_16 = NULL;
 
-  HRESULT hResult = SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, knownpath_16);
+  HRESULT hResult = SHGetKnownFolderPath(
+      FOLDERID_RoamingAppData, KF_FLAG_DEFAULT, NULL, &knownpath_16);
 
   if (hResult == S_OK) {
     conv_utf_16_to_8(knownpath_16, knownpath, MAX_PATH * 3);
+    CoTaskMemFree(knownpath_16);
     strcat(knownpath, "\\Blender Foundation\\Blender\\");
     strcat(knownpath, versionstr);
     return (GHOST_TUns8 *)knownpath;
diff --git a/intern/ghost/intern/GHOST_SystemPathsWin32.h b/intern/ghost/intern/GHOST_SystemPathsWin32.h
index 49d241df633..f1924ea51bc 100644
--- a/intern/ghost/intern/GHOST_SystemPathsWin32.h
+++ b/intern/ghost/intern/GHOST_SystemPathsWin32.h
@@ -28,8 +28,6 @@
 #  error WIN32 only!
 #endif  // WIN32
 
-#undef _WIN32_WINNT
-#define _WIN32_WINNT 0x501  // require Windows XP or newer
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 
diff --git a/intern/ghost/intern/GHOST_TaskbarWin32.h b/intern/ghost/intern/GHOST_TaskbarWin32.h
index b1b81337494..abf1172cea8 100644
--- a/intern/ghost/intern/GHOST_TaskbarWin32.h
+++ b/intern/ghost/intern/GHOST_TaskbarWin32.h
@@ -24,10 +24,6 @@
 #  error WIN32 only!
 #endif  // WIN32
 
-/* require Windows XP or newer */
-#undef _WIN32_WINNT
-#define _WIN32_WINNT 0x501
-
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <shlobj.h>



More information about the Bf-blender-cvs mailing list