System/Path/Windows: Make GetSystemLibraryPaths more generic.
authorMichael J. Spencer <bigcheesegs@gmail.com>
Tue, 9 Nov 2010 15:11:19 +0000 (15:11 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Tue, 9 Nov 2010 15:11:19 +0000 (15:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118505 91177308-0d34-0410-b5e6-96231b3b80d8

lib/System/Win32/Path.inc
lib/System/Win32/Win32.h

index 75f6b7134a48bfac00d2087b7c5036cdff7478bb..9187c8279381bb0df82b716c3a4098051f3a8ec4 100644 (file)
@@ -240,8 +240,32 @@ Path::GetRootDirectory() {
 
 void
 Path::GetSystemLibraryPaths(std::vector<sys::Path>& Paths) {
-  Paths.push_back(sys::Path("C:/WINDOWS/SYSTEM32"));
-  Paths.push_back(sys::Path("C:/WINDOWS"));
+  char buff[MAX_PATH];
+  // Generic form of C:\Windows\System32
+  HRESULT res =  SHGetFolderPathA(NULL,
+                                  CSIDL_FLAG_CREATE | CSIDL_SYSTEM,
+                                  NULL,
+                                  SHGFP_TYPE_CURRENT,
+                                  buff);
+  if (res != S_OK) {
+    assert(0 && "Failed to get system directory");
+    return;
+  }
+  Paths.push_back(sys::Path(buff));
+
+  // Reset buff.
+  buff[0] = 0;
+  // Generic form of C:\Windows
+  res =  SHGetFolderPathA(NULL,
+                          CSIDL_FLAG_CREATE | CSIDL_WINDOWS,
+                          NULL,
+                          SHGFP_TYPE_CURRENT,
+                          buff);
+  if (res != S_OK) {
+    assert(0 && "Failed to get windows directory");
+    return;
+  }
+  Paths.push_back(sys::Path(buff));
 }
 
 void
index d054812c76ca9b9651e55998ee224a4d55c106cb..00a7e75fc2a0c05a1c788b09b3e4f20f642fe046 100644 (file)
 
 // Require at least Windows 2000 API.
 #define _WIN32_WINNT 0x0500
+#define _WIN32_IE    0x0500 // MinGW at it again.
 #define WIN32_LEAN_AND_MEAN
 
 #include "llvm/Config/config.h" // Get build system configuration settings
 #include <Windows.h>
+#include <ShlObj.h>
 #include <cassert>
 #include <string>