From d5ac073cbc28e5d46e68eddefeb455766d89940d Mon Sep 17 00:00:00 2001 From: Dmitry Chapyshev Date: Tue, 16 Aug 2016 18:33:50 +0000 Subject: [PATCH] [INPUT] - Show localized keyboard layout name svn path=/trunk/; revision=72235 --- reactos/dll/cpl/input/layout_list.c | 68 +++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/reactos/dll/cpl/input/layout_list.c b/reactos/dll/cpl/input/layout_list.c index 636c33abef3..2dafdd64c19 100644 --- a/reactos/dll/cpl/input/layout_list.c +++ b/reactos/dll/cpl/input/layout_list.c @@ -148,13 +148,73 @@ LayoutList_Create(VOID) dwSize = sizeof(szBuffer); if (RegQueryValueExW(hLayoutKey, - L"Layout Text", + L"Layout Display Name", NULL, NULL, - (LPBYTE)szBuffer, &dwSize) == ERROR_SUCCESS) + (LPBYTE)szBuffer, &dwSize) == ERROR_SUCCESS && + szBuffer[0] == L'@') { - DWORD dwLayoutId = DWORDfromString(szLayoutId); + WCHAR szPath[MAX_PATH]; + WCHAR *pBuffer; + WCHAR *pIndex; + INT iIndex; - LayoutList_AppendNode(dwLayoutId, dwSpecialId, szBuffer); + /* Move to the position after the character "@" */ + pBuffer = szBuffer + 1; + + /* Get a pointer to the beginning ",-" */ + pIndex = wcsstr(pBuffer, L",-"); + + /* Convert the number in the string after the ",-" */ + iIndex = _wtoi(pIndex + 2); + + pIndex[0] = 0; + + if (ExpandEnvironmentStringsW(pBuffer, szPath, ARRAYSIZE(szPath)) != 0) + { + HANDLE hHandle; + + hHandle = LoadLibraryW(szPath); + if (hHandle != NULL) + { + INT iLength = LoadStringW(hHandle, iIndex, szBuffer, ARRAYSIZE(szBuffer)); + + FreeLibrary(hHandle); + + if (iLength != 0) + { + DWORD dwLayoutId = DWORDfromString(szLayoutId); + + LayoutList_AppendNode(dwLayoutId, dwSpecialId, szBuffer); + } + else + { + goto NotTranslated; + } + } + else + { + goto NotTranslated; + } + } + else + { + goto NotTranslated; + } + } + else + { +NotTranslated: + dwSize = sizeof(szBuffer); + + if (RegQueryValueExW(hLayoutKey, + L"Layout Text", + NULL, NULL, + (LPBYTE)szBuffer, &dwSize) == ERROR_SUCCESS) + { + DWORD dwLayoutId = DWORDfromString(szLayoutId); + + LayoutList_AppendNode(dwLayoutId, dwSpecialId, szBuffer); + } } } }