Changeset 53825 in vbox for trunk/src/VBox/Runtime/r3
- Timestamp:
- Jan 15, 2015 2:50:38 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/win/path-win.cpp
r52944 r53825 5 5 6 6 /* 7 * Copyright (C) 2006-201 1Oracle Corporation7 * Copyright (C) 2006-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 158 158 RTDECL(int) RTPathUserHome(char *pszPath, size_t cchPath) 159 159 { 160 /* 161 * Validate input 162 */ 163 AssertPtrReturn(pszPath, VERR_INVALID_POINTER); 164 AssertReturn(cchPath, VERR_INVALID_PARAMETER); 165 160 166 RTUTF16 wszPath[RTPATH_MAX]; 161 167 DWORD dwAttr; 162 163 /* 164 * There are multiple definitions for what WE think of as user home... 165 */ 166 if ( !GetEnvironmentVariableW(L"HOME", &wszPath[0], RTPATH_MAX) 168 bool fValidFolderPath = false; 169 170 /* 171 * Try with Windows XP+ functionality first. 172 */ 173 { 174 RTLDRMOD hShell32; 175 int rc = RTLdrLoadSystem("Shell32.dll", true /*fNoUnload*/, &hShell32); 176 if (RT_SUCCESS(rc)) 177 { 178 PFNSHGETFOLDERPATHW pfnSHGetFolderPathW; 179 rc = RTLdrGetSymbol(hShell32, "SHGetFolderPathW", (void**)&pfnSHGetFolderPathW); 180 if (RT_SUCCESS(rc)) 181 { 182 HRESULT hrc = pfnSHGetFolderPathW(0, CSIDL_PROFILE, NULL, SHGFP_TYPE_CURRENT, wszPath); 183 fValidFolderPath = (hrc == S_OK); 184 } 185 RTLdrClose(hShell32); 186 } 187 } 188 189 if ( !fValidFolderPath 167 190 || (dwAttr = GetFileAttributesW(&wszPath[0])) == INVALID_FILE_ATTRIBUTES 168 191 || !(dwAttr & FILE_ATTRIBUTE_DIRECTORY)) 169 192 { 193 /* 194 * Fall back to Windows specific environment variables. HOME is not used. 195 */ 170 196 if ( !GetEnvironmentVariableW(L"USERPROFILE", &wszPath[0], RTPATH_MAX) 171 197 || (dwAttr = GetFileAttributesW(&wszPath[0])) == INVALID_FILE_ATTRIBUTES
Note:
See TracChangeset
for help on using the changeset viewer.