Author: hpoussin Date: Sun Aug 27 19:18:20 2006 New Revision: 23747
URL: http://svn.reactos.org/svn/reactos?rev=23747&view=rev Log: Set user locale at login. User interface may now be (again) in other languages than English
Modified: trunk/reactos/base/system/winlogon/sas.c
Modified: trunk/reactos/base/system/winlogon/sas.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/winlogon/sas.c?... ============================================================================== --- trunk/reactos/base/system/winlogon/sas.c (original) +++ trunk/reactos/base/system/winlogon/sas.c Sun Aug 27 19:18:20 2006 @@ -35,6 +35,113 @@ L"taskmgr.exe"); }
+BOOL +SetDefaultLanguage( + IN BOOL UserProfile) +{ + HKEY BaseKey; + LPCWSTR SubKey; + LPCWSTR ValueName; + LONG rc; + HKEY hKey = NULL; + DWORD dwType, dwSize; + LPWSTR Value = NULL; + UNICODE_STRING ValueString; + NTSTATUS Status; + LCID Lcid; + BOOL ret = FALSE; + + if (UserProfile) + { + BaseKey = HKEY_CURRENT_USER; + SubKey = L"Control Panel\International"; + ValueName = L"Locale"; + } + else + { + BaseKey = HKEY_LOCAL_MACHINE; + SubKey = L"System\CurrentControlSet\Control\Nls\Language"; + ValueName = L"Default"; + } + + rc = RegOpenKeyExW( + BaseKey, + SubKey, + 0, + KEY_READ, + &hKey); + if (rc != ERROR_SUCCESS) + { + TRACE("RegOpenKeyEx() failed with error %lu\n", rc); + goto cleanup; + } + rc = RegQueryValueExW( + hKey, + ValueName, + NULL, + &dwType, + NULL, + &dwSize); + if (rc != ERROR_SUCCESS) + { + TRACE("RegQueryValueEx() failed with error %lu\n", rc); + goto cleanup; + } + else if (dwType != REG_SZ) + { + TRACE("Wrong type for %S\%S registry entry (got 0x%lx, expected 0x%lx)\n", + SubKey, ValueName, dwType, REG_SZ); + goto cleanup; + } + + Value = HeapAlloc(GetProcessHeap(), 0, dwSize + sizeof(UNICODE_NULL)); + if (!Value) + { + TRACE("HeapAlloc() failed\n"); + goto cleanup; + } + Value[dwSize / sizeof(WCHAR)] = UNICODE_NULL; + rc = RegQueryValueExW( + hKey, + ValueName, + NULL, + NULL, + (LPBYTE)Value, + &dwSize); + if (rc != ERROR_SUCCESS) + { + TRACE("RegQueryValueEx() failed with error %lu\n", rc); + goto cleanup; + } + + /* Convert Value to a Lcid */ + RtlInitUnicodeString(&ValueString, Value); + Status = RtlUnicodeStringToInteger(&ValueString, 16, &Lcid); + if (!NT_SUCCESS(Status)) + { + TRACE("RtlUnicodeStringToInteger() failed with status 0x%08lx\n", Status); + goto cleanup; + } + + TRACE("%s language is 0x%08lx\n", + UserProfile ? "User" : "System", Lcid); + Status = NtSetDefaultLocale(UserProfile, Lcid); + if (!NT_SUCCESS(Status)) + { + TRACE("NtSetDefaultLocale() failed with status 0x%08lx\n", Status); + goto cleanup; + } + + ret = TRUE; + +cleanup: + if (hKey) + RegCloseKey(hKey); + if (Value) + HeapFree(GetProcessHeap(), 0, Value); + return ret; +} + static BOOL HandleLogon( IN OUT PWLSESSION Session) @@ -85,6 +192,10 @@ //DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_LOADINGYOURPERSONALSETTINGS); //DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_APPLYINGYOURPERSONALSETTINGS);
+ /* Set default language */ + if (!SetDefaultLanguage(TRUE)) + return FALSE; + if (!Session->Gina.Functions.WlxActivateUserShell( Session->Gina.Context, L"Default", @@ -329,6 +440,8 @@ SwitchDesktop(Session->ApplicationDesktop); Session->LogonStatus = WKSTA_IS_LOGGED_ON; } + else + Session->Gina.Functions.WlxDisplaySASNotice(Session->Gina.Context); break; case WLX_SAS_ACTION_NONE: /* 0x02 */ break; @@ -682,6 +795,9 @@ goto cleanup; }
+ if (!SetDefaultLanguage(FALSE)) + return FALSE; + ret = TRUE;
cleanup: