[ros-diffs] [rharabien] 54212: [WINLOGON] - If no keyboard layout can be loaded, load US layout - Try to load all layouts from Preloaded key even if some of them fail

rharabien at svn.reactos.org rharabien at svn.reactos.org
Thu Oct 20 13:26:40 UTC 2011


Author: rharabien
Date: Thu Oct 20 13:26:39 2011
New Revision: 54212

URL: http://svn.reactos.org/svn/reactos?rev=54212&view=rev
Log:
[WINLOGON]
- If no keyboard layout can be loaded, load US layout
- Try to load all layouts from Preloaded key even if some of them fail

Modified:
    trunk/reactos/base/system/winlogon/winlogon.c

Modified: trunk/reactos/base/system/winlogon/winlogon.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/winlogon/winlogon.c?rev=54212&r1=54211&r2=54212&view=diff
==============================================================================
--- trunk/reactos/base/system/winlogon/winlogon.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/winlogon/winlogon.c [iso-8859-1] Thu Oct 20 13:26:39 2011
@@ -271,57 +271,61 @@
 InitKeyboardLayouts()
 {
     WCHAR wszKeyName[12], wszKLID[10];
-	DWORD dwSize = sizeof(wszKLID), dwType, i;
+	DWORD dwSize = sizeof(wszKLID), dwType, i = 1;
     HKEY hKey;
     UINT Flags;
     BOOL bRet = FALSE;
 
     /* Open registry key with preloaded layouts */
-	if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Keyboard Layout\\Preload", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
-	{
-	    ERR("RegOpenKeyExW failed!\n");
-	    return FALSE;
-	}
-
-    i = 1;
-    while(TRUE)
+	if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Keyboard Layout\\Preload", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
+	{
+        while(TRUE)
+        {
+            /* Read values with integer names only */
+            swprintf(wszKeyName, L"%d", i++);
+            if (RegQueryValueExW(hKey, wszKeyName, NULL, &dwType, (LPBYTE)wszKLID, &dwSize) != ERROR_SUCCESS)
+            {
+                /* There is no more entries */
+                break;
+            }
+
+            /* Only REG_SZ values are valid */
+            if (dwType != REG_SZ)
+            {
+                ERR("Wrong type: %ws!\n", wszKLID);
+                continue;
+            }
+
+            /* Load keyboard layout with given locale id */
+            Flags = KLF_SUBSTITUTE_OK;
+            if (i > 1)
+                Flags |= KLF_NOTELLSHELL|KLF_REPLACELANG;
+            else // First layout
+                Flags |= KLF_ACTIVATE; // |0x40000000
+            if (!LoadKeyboardLayoutW(wszKLID, Flags))
+            {
+                ERR("LoadKeyboardLayoutW(%ws) failed!\n", wszKLID);
+                continue;
+            }
+            else
+            {
+                /* We loaded at least one layout - success */
+                bRet = TRUE;
+            }
+        }
+
+        /* Close the key now */
+        RegCloseKey(hKey);
+	}
+	else
+	    WARN("RegOpenKeyExW(Keyboard Layout\\Preload) failed!\n");
+
+    if (!bRet)
     {
-        /* Read values with integer names only */
-        swprintf(wszKeyName, L"%d", i);
-        if (RegQueryValueExW(hKey, wszKeyName, NULL, &dwType, (LPBYTE)wszKLID, &dwSize) != ERROR_SUCCESS)
-        {
-            /* If we loaded at least one layout and there is no more
-               registry values return TRUE */
-            if (i > 1)
-                bRet = TRUE;
-            break;
-        }
-
-        /* Only REG_SZ values are valid */
-        if (dwType != REG_SZ)
-        {
-            ERR("Wrong type!\n");
-            break;
-        }
-
-        /* Load keyboard layout with given locale id */
-        Flags = KLF_SUBSTITUTE_OK;
-        if (i > 1)
-            Flags |= KLF_NOTELLSHELL|KLF_REPLACELANG;
-        else // First layout
-            Flags |= KLF_ACTIVATE; // |0x40000000
-        if (!LoadKeyboardLayoutW(wszKLID, Flags))
-        {
-            ERR("LoadKeyboardLayoutW failed!\n");
-            break;
-        }
-
-        /* Move to the next entry */
-        ++i;
+        /* If we failed, load US keyboard layout */
+        if (LoadKeyboardLayoutW(L"00000409", 0x04090409))
+            bRet = TRUE;
     }
-
-    /* Close the key now */
-	RegCloseKey(hKey);
 
     return bRet;
 }




More information about the Ros-diffs mailing list