https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8e1dea0c8c919555394e8…
commit 8e1dea0c8c919555394e89e354440814a281aaae
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Wed Jul 28 23:25:10 2021 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Wed Jul 28 23:25:10 2021 +0900
[IMM32] Implement ImmLoadLayout (#3854)
Implementing Japanese input... CORE-11700
---
dll/win32/imm32/imm.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++
dll/win32/imm32/imm32.spec | 2 +-
2 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c
index df4db4cfca1..1523c74dbbf 100644
--- a/dll/win32/imm32/imm.c
+++ b/dll/win32/imm32/imm.c
@@ -48,8 +48,14 @@ WINE_DEFAULT_DEBUG_CHANNEL(imm);
#define IMM_INIT_MAGIC 0x19650412
#define IMM_INVALID_CANDFORM ULONG_MAX
+#define REGKEY_KEYBOARD_LAYOUTS \
+ L"System\\CurrentControlSet\\Control\\Keyboard Layouts"
+#define REGKEY_IMM \
+ L"Software\\Microsoft\\Windows NT\\CurrentVersion\\IMM"
+
RTL_CRITICAL_SECTION g_csImeDpi;
PIMEDPI g_pImeDpiList = NULL;
+PSERVERINFO g_psi = NULL;
BOOL WINAPI User32InitializeImmEntryTable(DWORD);
@@ -105,6 +111,58 @@ Imm32NotifyAction(HIMC hIMC, HWND hwnd, DWORD dwAction, DWORD_PTR
dwIndex, DWORD
return TRUE;
}
+HKL WINAPI ImmLoadLayout(HKL hKL, PIMEINFOEX pImeInfoEx)
+{
+ DWORD cbData;
+ UNICODE_STRING UnicodeString;
+ HKEY hLayoutKey = NULL, hLayoutsKey = NULL;
+ LONG error;
+ NTSTATUS Status;
+ WCHAR szLayout[MAX_PATH];
+
+ TRACE("ImmLoadLayout(%p, %p)\n", hKL, pImeInfoEx);
+
+ if (IS_IME_HKL(hKL) ||
+ !g_psi || (g_psi->dwSRVIFlags & SRVINFO_METRICS) == 0 ||
+ ((PW32CLIENTINFO)NtCurrentTeb()->Win32ClientInfo)->W32ClientInfo[0] &
2)
+ {
+ UnicodeString.Buffer = szLayout;
+ UnicodeString.MaximumLength = sizeof(szLayout);
+ Status = RtlIntegerToUnicodeString((DWORD_PTR)hKL, 16, &UnicodeString);
+ if (!NT_SUCCESS(Status))
+ return NULL;
+
+ error = RegOpenKeyW(HKEY_LOCAL_MACHINE, REGKEY_KEYBOARD_LAYOUTS,
&hLayoutsKey);
+ if (error)
+ return NULL;
+
+ error = RegOpenKeyW(hLayoutsKey, szLayout, &hLayoutKey);
+ }
+ else
+ {
+ error = RegOpenKeyW(HKEY_LOCAL_MACHINE, REGKEY_IMM, &hLayoutKey);
+ }
+
+ if (error)
+ {
+ ERR("RegOpenKeyW error: 0x%08lX\n", error);
+ hKL = NULL;
+ }
+ else
+ {
+ cbData = sizeof(pImeInfoEx->wszImeFile);
+ error = RegQueryValueExW(hLayoutKey, L"Ime File", 0, 0,
+ (LPBYTE)pImeInfoEx->wszImeFile, &cbData);
+ if (error)
+ hKL = NULL;
+ }
+
+ RegCloseKey(hLayoutKey);
+ if (hLayoutsKey)
+ RegCloseKey(hLayoutsKey);
+ return hKL;
+}
+
typedef struct _tagImmHkl{
struct list entry;
HKL hkl;
diff --git a/dll/win32/imm32/imm32.spec b/dll/win32/imm32/imm32.spec
index 365d6726122..d7a269dd5be 100644
--- a/dll/win32/imm32/imm32.spec
+++ b/dll/win32/imm32/imm32.spec
@@ -69,7 +69,7 @@
@ stdcall ImmIsUIMessageA(long long long long)
@ stdcall ImmIsUIMessageW(long long long long)
@ stdcall -stub ImmLoadIME(long)
-@ stdcall -stub ImmLoadLayout(long ptr)
+@ stdcall ImmLoadLayout(ptr ptr)
@ stdcall ImmLockClientImc(ptr)
@ stdcall ImmLockIMC(ptr)
@ stdcall ImmLockIMCC(ptr)