[USERENV]
authorEric Kohl <eric.kohl@reactos.org>
Sat, 7 Nov 2015 16:40:33 +0000 (16:40 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sat, 7 Nov 2015 16:40:33 +0000 (16:40 +0000)
CreateEnvironmentBlock: Set or overwrite the SystemRoot, SystemDrive and USERPROFILE environment variables of the new environment block.

svn path=/trunk/; revision=69834

reactos/dll/win32/userenv/environment.c

index cb1b26e..55f363f 100644 (file)
@@ -431,6 +431,29 @@ CreateEnvironmentBlock(LPVOID *lpEnvironment,
         return FALSE;
     }
 
         return FALSE;
     }
 
+    /* Set 'SystemRoot' variable */
+    Length = MAX_PATH;
+    if (GetEnvironmentVariableW(L"SystemRoot",
+                                Buffer,
+                                Length))
+    {
+        SetUserEnvironmentVariable(lpEnvironment,
+                                   L"SystemRoot",
+                                   Buffer,
+                                   FALSE);
+    }
+
+    /* Set 'SystemDrive' variable */
+    if (GetEnvironmentVariableW(L"SystemDrive",
+                                Buffer,
+                                Length))
+    {
+        SetUserEnvironmentVariable(lpEnvironment,
+                                   L"SystemDrive",
+                                   Buffer,
+                                   FALSE);
+    }
+
     /* Set 'COMPUTERNAME' variable */
     Length = MAX_PATH;
     if (GetComputerNameW(Buffer,
     /* Set 'COMPUTERNAME' variable */
     Length = MAX_PATH;
     if (GetComputerNameW(Buffer,
@@ -453,6 +476,17 @@ CreateEnvironmentBlock(LPVOID *lpEnvironment,
                                    FALSE);
     }
 
                                    FALSE);
     }
 
+    /* Set 'USERSPROFILE' variable to the default users profile */
+    Length = MAX_PATH;
+    if (GetDefaultUserProfileDirectory(Buffer,
+                                       &Length))
+    {
+        SetUserEnvironmentVariable(lpEnvironment,
+                                   L"USERPROFILE",
+                                   Buffer,
+                                   TRUE);
+    }
+
     lError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
                            L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion",
                            0,
     lError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
                            L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion",
                            0,