Skip to content

Commit 181fd8c

Browse files
committed
System/Path/Windows: Make GetSystemLibraryPaths more generic.
llvm-svn: 118505
1 parent bb6e51c commit 181fd8c

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

llvm/lib/System/Win32/Path.inc

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,32 @@ Path::GetRootDirectory() {
240240

241241
void
242242
Path::GetSystemLibraryPaths(std::vector<sys::Path>& Paths) {
243-
Paths.push_back(sys::Path("C:/WINDOWS/SYSTEM32"));
244-
Paths.push_back(sys::Path("C:/WINDOWS"));
243+
char buff[MAX_PATH];
244+
// Generic form of C:\Windows\System32
245+
HRESULT res = SHGetFolderPathA(NULL,
246+
CSIDL_FLAG_CREATE | CSIDL_SYSTEM,
247+
NULL,
248+
SHGFP_TYPE_CURRENT,
249+
buff);
250+
if (res != S_OK) {
251+
assert(0 && "Failed to get system directory");
252+
return;
253+
}
254+
Paths.push_back(sys::Path(buff));
255+
256+
// Reset buff.
257+
buff[0] = 0;
258+
// Generic form of C:\Windows
259+
res = SHGetFolderPathA(NULL,
260+
CSIDL_FLAG_CREATE | CSIDL_WINDOWS,
261+
NULL,
262+
SHGFP_TYPE_CURRENT,
263+
buff);
264+
if (res != S_OK) {
265+
assert(0 && "Failed to get windows directory");
266+
return;
267+
}
268+
Paths.push_back(sys::Path(buff));
245269
}
246270

247271
void

llvm/lib/System/Win32/Win32.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818

1919
// Require at least Windows 2000 API.
2020
#define _WIN32_WINNT 0x0500
21+
#define _WIN32_IE 0x0500 // MinGW at it again.
2122
#define WIN32_LEAN_AND_MEAN
2223

2324
#include "llvm/Config/config.h" // Get build system configuration settings
2425
#include <Windows.h>
26+
#include <ShlObj.h>
2527
#include <cassert>
2628
#include <string>
2729

0 commit comments

Comments
 (0)