Skip to content

WinAPI reference

Davide Beatrici edited this page Jul 15, 2021 · 5 revisions

LoadKeyboardLayout()

Official documentation

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadkeyboardlayouta

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadkeyboardlayoutw

Purpose

Loads the layout, making it appear in the language bar.

Please note that:

  1. The layout does not appear in Settings -> Time & language -> Language -> <language>.
    To remove it you can either:
  2. The layout is not loaded automatically on next boot/login, you have to call InstallLayoutOrTip() to achieve that behavior.

InstallLayoutOrTip()

Official documentation

https://docs.microsoft.com/en-us/windows/win32/tsf/installlayoutortip

Purpose

  • Loads the layout, making it appear in the language bar.
  • Makes the layout available permanently (i.e. automatically loaded at boot/login).
    As a result, the layout also appears in Settings -> Time & language -> Language -> <language>.

Remarks

  • Has to be imported manually.
  • Ignores the return value of LoadKeyboardLayout().
    As a result, the function returns TRUE even if the layout is not loaded.

InstallInputLayout()

Signature

WINAPI BOOL InstallInputLayout(LCID Language, DWORD KLID, BOOL Load, PVOID Unused, BOOL DefaultUser, BOOL Unknown);

Parameters

Language: The language the layout should be installed for. Example: 0x0409

KLID: The input locale identifier. Example: 0xa0000409

Load: Load the layout once installed.

DefaultUser: Alter HKEY_USERS\.DEFAULT\Keyboard Layout instead of HKEY_CURRENT_USER\Keyboard Layout.

Unknown: MSKLC sets it to FALSE. The value is passed to UpdateDefaultHotKey(), which seems to use it to decide how the hotkey to toggle the layout is set.

Purpose

MSI packages built by MSKLC use it as fallback for InstallLayoutOrTip(), to support Windows versions older than Vista.

Remarks

Has to be imported manually from input.dll, ordinal 102.

UnInstallInputLayout()

Signature

WINAPI BOOL UnInstallInputLayout(LCID Language, DWORD KLID, BOOL DefaultUser);

Parameters

Language: The language the layout should be uninstalled for. Example: 0x0409

KLID: The input locale identifier. Example: 0xa0000409

DefaultUser: Alter HKEY_USERS\.DEFAULT\Keyboard Layout instead of HKEY_CURRENT_USER\Keyboard Layout.

Purpose

MSI packages built by MSKLC use it as fallback for InstallLayoutOrTip(), to support Windows versions older than Vista.

Remarks

Has to be imported manually from input.dll, ordinal 103.