mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 23:43:39 +00:00
[SHELL32][EXPLORER] Update system-wide environment variables (#663)
- Implement shell32 RegenerateUserEnvironment() function and use it. - CShellBrowser and CDesktopBrowser implements WM_SETTINGCHANGE actions. CORE-1459, CORE-14397
This commit is contained in:
parent
25004bb5b4
commit
a882ec7a02
7 changed files with 58 additions and 16 deletions
|
@ -63,6 +63,48 @@ AddCommasW(DWORD lValue, LPWSTR lpNumber)
|
|||
return lpNumber;
|
||||
}
|
||||
|
||||
/*
|
||||
* Implemented
|
||||
*/
|
||||
EXTERN_C BOOL
|
||||
WINAPI
|
||||
RegenerateUserEnvironment(LPVOID *lpEnvironment, BOOL bUpdateSelf)
|
||||
{
|
||||
HANDLE hUserToken;
|
||||
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_READ | TOKEN_WRITE, &hUserToken))
|
||||
return FALSE;
|
||||
|
||||
BOOL bResult = CreateEnvironmentBlock(lpEnvironment, hUserToken, TRUE);
|
||||
if (!bResult || !lpEnvironment)
|
||||
{
|
||||
CloseHandle(hUserToken);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (bUpdateSelf)
|
||||
{
|
||||
LPWSTR pszz = (LPWSTR)*lpEnvironment;
|
||||
if (!pszz)
|
||||
return FALSE;
|
||||
|
||||
while (*pszz)
|
||||
{
|
||||
size_t cch = wcslen(pszz);
|
||||
LPWSTR pchEqual = wcschr(pszz, L'=');
|
||||
if (pchEqual)
|
||||
{
|
||||
CStringW strName(pszz, pchEqual - pszz);
|
||||
SetEnvironmentVariableW(strName, pchEqual + 1);
|
||||
}
|
||||
pszz += cch + 1;
|
||||
}
|
||||
}
|
||||
|
||||
CloseHandle(hUserToken);
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* Default ClassFactory types
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue