https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7ee41e9e6091f3f18c6ef…
commit 7ee41e9e6091f3f18c6ef652c522f5207bb8f3fb
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Sat Apr 29 07:28:56 2023 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Sat Apr 29 07:28:56 2023 +0900
[KBSWITCH] Delete SHLoadRegUIString hack (#5260)
Because shlwapi!SHLoadRegUIString function is already implemented, so we don't
need the hack any more. CORE-10667
---
base/applications/kbswitch/CMakeLists.txt | 2 +-
base/applications/kbswitch/kbswitch.c | 51 +++++--------------------------
2 files changed, 9 insertions(+), 44 deletions(-)
diff --git a/base/applications/kbswitch/CMakeLists.txt
b/base/applications/kbswitch/CMakeLists.txt
index ede579f6181..9cf01e40398 100644
--- a/base/applications/kbswitch/CMakeLists.txt
+++ b/base/applications/kbswitch/CMakeLists.txt
@@ -2,7 +2,7 @@
add_rc_deps(kbswitch.rc ${CMAKE_CURRENT_SOURCE_DIR}/res/kbswitch.ico)
add_executable(kbswitch kbswitch.c kbswitch.rc)
set_module_type(kbswitch win32gui UNICODE)
-add_importlibs(kbswitch advapi32 imm32 user32 shell32 gdi32 msvcrt kernel32)
+add_importlibs(kbswitch advapi32 imm32 user32 shell32 shlwapi gdi32 msvcrt kernel32)
add_cd_file(TARGET kbswitch DESTINATION reactos/system32 FOR all)
add_subdirectory(kbsdll)
diff --git a/base/applications/kbswitch/kbswitch.c
b/base/applications/kbswitch/kbswitch.c
index 29f59db2f4c..984e2801bc3 100644
--- a/base/applications/kbswitch/kbswitch.c
+++ b/base/applications/kbswitch/kbswitch.c
@@ -8,6 +8,8 @@
*/
#include "kbswitch.h"
+#include <shlobj.h>
+#include <shlwapi_undoc.h>
#include <imm.h>
/*
@@ -96,11 +98,10 @@ static BOOL
GetLayoutName(LPCTSTR szLayoutNum, LPTSTR szName, SIZE_T NameLength)
{
HKEY hKey;
+ HRESULT hr;
DWORD dwBufLen;
- TCHAR szBuf[MAX_PATH], szDispName[MAX_PATH], szIndex[MAX_PATH], szPath[MAX_PATH];
+ TCHAR szBuf[MAX_PATH];
TCHAR szLCID[CCH_LAYOUT_ID + 1];
- HANDLE hLib;
- UINT i, j, k;
if (!GetLayoutID(szLayoutNum, szLCID, ARRAYSIZE(szLCID)))
return FALSE;
@@ -109,50 +110,14 @@ GetLayoutName(LPCTSTR szLayoutNum, LPTSTR szName, SIZE_T
NameLength)
_T("SYSTEM\\CurrentControlSet\\Control\\Keyboard
Layouts\\%s"), szLCID);
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, szBuf, 0, KEY_QUERY_VALUE, &hKey) !=
ERROR_SUCCESS)
- {
return FALSE;
- }
/* Use "Layout Display Name" value as an entry name if possible */
- dwBufLen = sizeof(szDispName);
- if (RegQueryValueEx(hKey, _T("Layout Display Name"), NULL, NULL,
- (LPBYTE)szDispName, &dwBufLen) == ERROR_SUCCESS)
+ hr = SHLoadRegUIString(hKey, _T("Layout Display Name"), szName,
NameLength);
+ if (SUCCEEDED(hr))
{
- /* FIXME: Use shlwapi!SHLoadRegUIStringW instead if it was implemented */
- if (szDispName[0] == '@')
- {
- size_t len = _tcslen(szDispName);
-
- for (i = 0; i < len; 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, ARRAYSIZE(szPath)))
- {
- hLib = LoadLibrary(szPath);
- if (hLib)
- {
- if (LoadString(hLib, _ttoi(szIndex), szPath, ARRAYSIZE(szPath)))
- {
- StringCchCopy(szName, NameLength, szPath);
- RegCloseKey(hKey);
- FreeLibrary(hLib);
- return TRUE;
- }
- FreeLibrary(hLib);
- }
- }
- }
+ RegCloseKey(hKey);
+ return TRUE;
}
/* Otherwise, use "Layout Text" value as an entry name */