From: Colin Finck Date: Mon, 2 Feb 2009 23:08:51 +0000 (+0000) Subject: Set the APPDATA environment variable when logging in based on the information SHGetFo... X-Git-Tag: ReactOS-0.3.8~4^2~6 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=d7ca3b27e6f1e342c699a36bad48bd5c049e8c92 Set the APPDATA environment variable when logging in based on the information SHGetFolderPathW returns for the passed User Token. Windows seems to do this the same way (verified with GNU strings) svn path=/trunk/; revision=39295 --- diff --git a/reactos/base/system/winlogon/sas.c b/reactos/base/system/winlogon/sas.c index f560187d702..1acadde1219 100644 --- a/reactos/base/system/winlogon/sas.c +++ b/reactos/base/system/winlogon/sas.c @@ -175,6 +175,9 @@ HandleLogon( SIZE_T EnvBlockSize = 0, ProfileSize = 0; BOOLEAN Old; BOOL ret = FALSE; + UNICODE_STRING VariableName; + UNICODE_STRING VariableValue; + WCHAR AppDataPath[MAX_PATH]; /* Loading personal settings */ DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_LOADINGYOURPERSONALSETTINGS); @@ -219,6 +222,18 @@ HandleLogon( goto cleanup; } + /* Use SHGetFolderPathW for getting the AppData path */ + if(SHGetFolderPathW(NULL, CSIDL_APPDATA, Session->UserToken, SHGFP_TYPE_CURRENT, AppDataPath) == E_FAIL) + { + WARN("WL: SHGetFolderPathW() failed\n"); + goto cleanup; + } + + /* Some environment variables need to be set by winlogon (verified against Windows XP winlogon) */ + RtlInitUnicodeString(&VariableName, L"APPDATA"); + RtlInitUnicodeString(&VariableValue, AppDataPath); + RtlSetEnvironmentVariable((PWSTR*)&lpEnvironment, &VariableName, &VariableValue); + if (Session->Profile->dwType == WLX_PROFILE_TYPE_V2_0 && Session->Profile->pszEnvironment) { /* Count required size for full environment */ @@ -264,6 +279,8 @@ HandleLogon( DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_APPLYINGYOURPERSONALSETTINGS); UpdatePerUserSystemParameters(0, TRUE); + /* FIXME: Set the "Volatile Environment" key for the new user */ + /* Set default language */ if (!SetDefaultLanguage(TRUE)) { diff --git a/reactos/base/system/winlogon/winlogon.h b/reactos/base/system/winlogon/winlogon.h index 11860504bcd..4d9778b63c1 100644 --- a/reactos/base/system/winlogon/winlogon.h +++ b/reactos/base/system/winlogon/winlogon.h @@ -39,6 +39,7 @@ #include #include #include +#include #include diff --git a/reactos/base/system/winlogon/winlogon.rbuild b/reactos/base/system/winlogon/winlogon.rbuild index 69505abf118..0e35bd24ff6 100644 --- a/reactos/base/system/winlogon/winlogon.rbuild +++ b/reactos/base/system/winlogon/winlogon.rbuild @@ -9,6 +9,7 @@ advapi32 userenv secur32 + shell32 sas.c screensaver.c setup.c