- Implement reading user shell folders from registry
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Sun, 15 Nov 2009 19:08:27 +0000 (19:08 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Sun, 15 Nov 2009 19:08:27 +0000 (19:08 +0000)
See issue #4206 for more details.

svn path=/trunk/; revision=44177

reactos/dll/win32/shell32/shellpath.c

index 5a39c83..76fc17c 100644 (file)
@@ -1011,7 +1011,9 @@ static HRESULT _SHGetUserShellFolderPath(HKEY rootKey, LPCWSTR userPrefix,
  */
 static HRESULT _SHGetDefaultValue(BYTE folder, LPWSTR pszPath)
 {
+    DWORD dwSize;
     HRESULT hr;
+    HKEY hKey;
     WCHAR resourcePath[MAX_PATH];
     LPCWSTR pDefaultPath = NULL;
 
@@ -1022,6 +1024,18 @@ static HRESULT _SHGetDefaultValue(BYTE folder, LPWSTR pszPath)
     if (!pszPath)
         return E_INVALIDARG;
 
+    if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
+    {
+        /* FIXME assume MAX_PATH size */
+        dwSize = MAX_PATH * sizeof(WCHAR);
+        if (RegQueryValueExW(hKey, CSIDL_Data[folder].szValueName, NULL, NULL, (LPBYTE)pszPath, &dwSize) == ERROR_SUCCESS)
+        {
+            RegCloseKey(hKey);
+            return S_OK;
+        }
+        RegCloseKey(hKey);
+    }
+
     if (CSIDL_Data[folder].szDefaultPath &&
      IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath))
     {