[USERENV]

CreateEnvironmentBlock: Set or overwrite the SystemRoot, SystemDrive and USERPROFILE environment variables of the new environment block.

svn path=/trunk/; revision=69834
This commit is contained in:
Eric Kohl 2015-11-07 16:40:33 +00:00
parent fbf5850ab6
commit 3b67603f55

View file

@ -431,6 +431,29 @@ CreateEnvironmentBlock(LPVOID *lpEnvironment,
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,
@ -453,6 +476,17 @@ CreateEnvironmentBlock(LPVOID *lpEnvironment,
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,