https://git.reactos.org/?p=reactos.git;a=commitdiff;h=063e5e251412e01b70301…
commit 063e5e251412e01b70301451b75ae15bb3106a13
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Wed Jul 31 03:50:29 2024 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Wed Jul 31 03:50:29 2024 +0900
[USER32] Simplify CliSaveImeHotKey (#7199)
Code diet. RegCreateKeyExW will
create sub-keys recursively, so
this code is okay.
JIRA issue: CORE-19268
Simplify registry key creation code.
---
win32ss/user/user32/windows/input.c | 63 ++++++++++++-------------------------
1 file changed, 20 insertions(+), 43 deletions(-)
diff --git a/win32ss/user/user32/windows/input.c b/win32ss/user/user32/windows/input.c
index dc6ddaff5f7..988254d2fae 100644
--- a/win32ss/user/user32/windows/input.c
+++ b/win32ss/user/user32/windows/input.c
@@ -211,68 +211,45 @@ CliSaveImeHotKey(DWORD dwID, UINT uModifiers, UINT uVirtualKey, HKL
hKL, BOOL bD
{
WCHAR szName[MAX_PATH];
LONG error;
- HKEY hControlPanel = NULL, hInputMethod = NULL, hHotKeys = NULL, hKey = NULL;
+ HKEY hKey;
BOOL ret = FALSE, bRevertOnFailure = FALSE;
+ StringCchPrintfW(szName, _countof(szName),
+ L"Control Panel\\Input Method\\Hot Keys\\%08lX", dwID);
+
if (bDelete)
{
- StringCchPrintfW(szName, _countof(szName),
- L"Control Panel\\Input Method\\Hot Keys\\%08lX",
dwID);
error = RegDeleteKeyW(HKEY_CURRENT_USER, szName);
return (error == ERROR_SUCCESS);
}
- // Open "Control Panel"
- error = RegCreateKeyExW(HKEY_CURRENT_USER, L"Control Panel", 0, NULL, 0,
KEY_ALL_ACCESS,
- NULL, &hControlPanel, NULL);
+ error = RegCreateKeyExW(HKEY_CURRENT_USER, szName, 0, NULL, 0, KEY_WRITE, NULL,
&hKey, NULL);
if (error == ERROR_SUCCESS)
{
- // Open "Input Method"
- error = RegCreateKeyExW(hControlPanel, L"Input Method", 0, NULL, 0,
KEY_ALL_ACCESS,
- NULL, &hInputMethod, NULL);
+ bRevertOnFailure = TRUE;
+
+ // Set "Virtual Key"
+ error = RegSetValueExW(hKey, L"Virtual Key", 0, REG_BINARY,
+ (LPBYTE)&uVirtualKey, sizeof(uVirtualKey));
if (error == ERROR_SUCCESS)
{
- // Open "Hot Keys"
- error = RegCreateKeyExW(hInputMethod, L"Hot Keys", 0, NULL, 0,
KEY_ALL_ACCESS,
- NULL, &hHotKeys, NULL);
+ // Set "Key Modifiers"
+ error = RegSetValueExW(hKey, L"Key Modifiers", 0, REG_BINARY,
+ (LPBYTE)&uModifiers, sizeof(uModifiers));
if (error == ERROR_SUCCESS)
{
- // Open "Key"
- StringCchPrintfW(szName, _countof(szName), L"%08lX", dwID);
- error = RegCreateKeyExW(hHotKeys, szName, 0, NULL, 0, KEY_ALL_ACCESS,
- NULL, &hKey, NULL);
+ // Set "Target IME"
+ error = RegSetValueExW(hKey, L"Target IME", 0, REG_BINARY,
+ (LPBYTE)&hKL, sizeof(hKL));
if (error == ERROR_SUCCESS)
{
- bRevertOnFailure = TRUE;
-
- // Set "Virtual Key"
- error = RegSetValueExW(hKey, L"Virtual Key", 0,
REG_BINARY,
- (LPBYTE)&uVirtualKey,
sizeof(uVirtualKey));
- if (error == ERROR_SUCCESS)
- {
- // Set "Key Modifiers"
- error = RegSetValueExW(hKey, L"Key Modifiers", 0,
REG_BINARY,
- (LPBYTE)&uModifiers,
sizeof(uModifiers));
- if (error == ERROR_SUCCESS)
- {
- // Set "Target IME"
- error = RegSetValueExW(hKey, L"Target IME", 0,
REG_BINARY,
- (LPBYTE)&hKL, sizeof(hKL));
- if (error == ERROR_SUCCESS)
- {
- // Success!
- ret = TRUE;
- bRevertOnFailure = FALSE;
- }
- }
- }
- RegCloseKey(hKey);
+ // Success!
+ ret = TRUE;
+ bRevertOnFailure = FALSE;
}
- RegCloseKey(hHotKeys);
}
- RegCloseKey(hInputMethod);
}
- RegCloseKey(hControlPanel);
+ RegCloseKey(hKey);
}
if (bRevertOnFailure)