From b00f2fbdd7cd8294b3dfb489f89e2d1f2cc68ba3 Mon Sep 17 00:00:00 2001 From: Dmitry Chapyshev Date: Sun, 18 May 2008 10:37:32 +0000 Subject: [PATCH] - Add hotkeys settings to registry svn path=/trunk/; revision=33570 --- reactos/base/setup/usetup/mui.c | 91 +++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/reactos/base/setup/usetup/mui.c b/reactos/base/setup/usetup/mui.c index bf9381da6a2..be91246680c 100644 --- a/reactos/base/setup/usetup/mui.c +++ b/reactos/base/setup/usetup/mui.c @@ -273,6 +273,90 @@ MUIGetString(ULONG Number) return ""; } +static BOOLEAN +AddHotkeySettings(IN LPCWSTR Hotkey, IN LPCWSTR LangHotkey, IN LPCWSTR LayoutHotkey) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING KeyName; + UNICODE_STRING ValueName; + HANDLE KeyHandle; + ULONG Disposition; + NTSTATUS Status; + + RtlInitUnicodeString(&KeyName, + L"\\Registry\\User\\.DEFAULT\\Keyboard Layout\\Toggle"); + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + + Status = NtCreateKey(&KeyHandle, + KEY_ALL_ACCESS, + &ObjectAttributes, + 0, + NULL, + 0, + &Disposition); + + if(!NT_SUCCESS(Status)) + { + DPRINT1("NtCreateKey() failed (Status %lx)\n", Status); + return FALSE; + } + + RtlInitUnicodeString(&ValueName, + L"Hotkey"); + + Status = NtSetValueKey(KeyHandle, + &ValueName, + 0, + REG_SZ, + (PVOID)Hotkey, + (1 + 1) * sizeof(WCHAR)); + if (!NT_SUCCESS(Status)) + { + DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status); + NtClose(KeyHandle); + return FALSE; + } + + RtlInitUnicodeString(&ValueName, + L"Language Hotkey"); + + Status = NtSetValueKey(KeyHandle, + &ValueName, + 0, + REG_SZ, + (PVOID)LangHotkey, + (1 + 1) * sizeof(WCHAR)); + if (!NT_SUCCESS(Status)) + { + DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status); + NtClose(KeyHandle); + return FALSE; + } + + RtlInitUnicodeString(&ValueName, + L"Layout Hotkey"); + + Status = NtSetValueKey(KeyHandle, + &ValueName, + 0, + REG_SZ, + (PVOID)LayoutHotkey, + (1 + 1) * sizeof(WCHAR)); + if (!NT_SUCCESS(Status)) + { + DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status); + NtClose(KeyHandle); + return FALSE; + } + + NtClose(KeyHandle); + return TRUE; +} + static BOOLEAN AddKbLayoutsToRegistry(IN LPCWSTR DefKbLayout, IN LPCWSTR SecKbLayout) { @@ -374,7 +458,14 @@ AddKbLayoutsToRegistry(IN LPCWSTR DefKbLayout, IN LPCWSTR SecKbLayout) NtClose(KeyHandle); return FALSE; } + + /* + Switching input languages - Ctrl + Shift + Switching keyboard layouts - Left Alt + Shift + */ + AddHotkeySettings(L"2", L"2", L"1"); } + else AddHotkeySettings(L"3", L"3", L"3"); // Off all hotkeys NtClose(KeyHandle); return TRUE;