mirror of
https://github.com/reactos/reactos.git
synced 2025-07-30 09:52:14 +00:00
[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 svn path=/trunk/; revision=54212
This commit is contained in:
parent
28b24fc9ba
commit
7255e6ef04
1 changed files with 42 additions and 38 deletions
|
@ -271,58 +271,62 @@ static BOOL
|
||||||
InitKeyboardLayouts()
|
InitKeyboardLayouts()
|
||||||
{
|
{
|
||||||
WCHAR wszKeyName[12], wszKLID[10];
|
WCHAR wszKeyName[12], wszKLID[10];
|
||||||
DWORD dwSize = sizeof(wszKLID), dwType, i;
|
DWORD dwSize = sizeof(wszKLID), dwType, i = 1;
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
UINT Flags;
|
UINT Flags;
|
||||||
BOOL bRet = FALSE;
|
BOOL bRet = FALSE;
|
||||||
|
|
||||||
/* Open registry key with preloaded layouts */
|
/* Open registry key with preloaded layouts */
|
||||||
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Keyboard Layout\\Preload", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
|
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Keyboard Layout\\Preload", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
ERR("RegOpenKeyExW failed!\n");
|
while(TRUE)
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = 1;
|
|
||||||
while(TRUE)
|
|
||||||
{
|
|
||||||
/* 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
|
/* Read values with integer names only */
|
||||||
registry values return TRUE */
|
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)
|
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;
|
bRet = TRUE;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only REG_SZ values are valid */
|
/* Close the key now */
|
||||||
if (dwType != REG_SZ)
|
RegCloseKey(hKey);
|
||||||
{
|
}
|
||||||
ERR("Wrong type!\n");
|
else
|
||||||
break;
|
WARN("RegOpenKeyExW(Keyboard Layout\\Preload) failed!\n");
|
||||||
}
|
|
||||||
|
|
||||||
/* Load keyboard layout with given locale id */
|
if (!bRet)
|
||||||
Flags = KLF_SUBSTITUTE_OK;
|
{
|
||||||
if (i > 1)
|
/* If we failed, load US keyboard layout */
|
||||||
Flags |= KLF_NOTELLSHELL|KLF_REPLACELANG;
|
if (LoadKeyboardLayoutW(L"00000409", 0x04090409))
|
||||||
else // First layout
|
bRet = TRUE;
|
||||||
Flags |= KLF_ACTIVATE; // |0x40000000
|
|
||||||
if (!LoadKeyboardLayoutW(wszKLID, Flags))
|
|
||||||
{
|
|
||||||
ERR("LoadKeyboardLayoutW failed!\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Move to the next entry */
|
|
||||||
++i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close the key now */
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
|
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue