Author: dchapyshev
Date: Fri May 2 01:42:45 2008
New Revision: 33229
URL:
http://svn.reactos.org/svn/reactos?rev=33229&view=rev
Log:
- Getting a localized layout names from input.dll
Modified:
trunk/reactos/base/applications/kbswitch/kbswitch.c
Modified: trunk/reactos/base/applications/kbswitch/kbswitch.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/kbswitch…
==============================================================================
--- trunk/reactos/base/applications/kbswitch/kbswitch.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/kbswitch/kbswitch.c [iso-8859-1] Fri May 2 01:42:45
2008
@@ -185,8 +185,10 @@
{
HKEY hKey;
DWORD dwBufLen;
- TCHAR szBuf[MAX_PATH];
+ TCHAR szBuf[MAX_PATH], szDispName[MAX_PATH], szIndex[MAX_PATH], szPath[MAX_PATH];
TCHAR szLCID[CCH_LAYOUT_ID + 1];
+ HANDLE hLib;
+ int i, j, k;
if(!GetLayoutID(szLayoutNum, szLCID))
return FALSE;
@@ -195,18 +197,53 @@
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCTSTR)szBuf, 0, KEY_QUERY_VALUE, &hKey)
== ERROR_SUCCESS)
{
- dwBufLen = MAX_PATH * sizeof(TCHAR);
-
- if(RegQueryValueEx(hKey, _T("Layout Text"), NULL, NULL, (LPBYTE)szName,
&dwBufLen) != ERROR_SUCCESS)
+ dwBufLen = sizeof(szBuf);
+
+ if (RegQueryValueEx(hKey, _T("Layout Display Name"), NULL, NULL,
(LPBYTE)szDispName, &dwBufLen) == ERROR_SUCCESS)
+ {
+ if (szDispName[0] == '@')
+ {
+ for (i = 0; i < _tcslen(szDispName); i++)
+ {
+ if ((szDispName[i] == ',') && (szDispName[i + 1] ==
'-'))
+ {
+ for (j = i + 2, k = 0; j < _tcslen(szDispName)+1; j++, k++)
+ {
+ szIndex[k] = szDispName[j];
+ }
+ szDispName[i - 1] = '\0';
+ break;
+ }
+ else szDispName[i] = szDispName[i + 1];
+ }
+
+ if (ExpandEnvironmentStrings(szDispName, szPath, MAX_PATH))
+ {
+ hLib = LoadLibrary(szPath);
+ if (hLib)
+ {
+ if (LoadString(hLib, _ttoi(szIndex), szPath, sizeof(szPath) /
sizeof(TCHAR)) != 0)
+ {
+ _tcscpy(szName, szPath);
+ RegCloseKey(hKey);
+ return TRUE;
+ }
+ FreeLibrary(hLib);
+ }
+ }
+ }
+ }
+
+ dwBufLen = sizeof(szBuf);
+
+ if (RegQueryValueEx(hKey, _T("Layout Text"), NULL, NULL,
(LPBYTE)szName, &dwBufLen) == ERROR_SUCCESS)
{
RegCloseKey(hKey);
- return FALSE;
- }
-
- RegCloseKey(hKey);
- }
-
- return TRUE;
+ return TRUE;
+ }
+ }
+
+ return FALSE;
}
BOOL CALLBACK
@@ -343,7 +380,7 @@
shInputDll.cbSize = sizeof(shInputDll);
shInputDll.hwnd = hwnd;
shInputDll.lpVerb = _T("open");
- shInputDll.lpFile = _T("RunDll32.exe");
+ shInputDll.lpFile = _T("rundll32.exe");
shInputDll.lpParameters = _T("shell32.dll,Control_RunDLL
input.dll");
if (!ShellExecuteEx(&shInputDll))
@@ -404,7 +441,7 @@
DispatchMessage(&msg);
}
- CloseHandle(hMutex);
+ if (hMutex) CloseHandle(hMutex);
return 0;
}