Click to Rate and Give Feedback
MSDN
MSDN Library
User Interface
User Input
Keyboard Input
Functions
 GetKeyboardLayout Function

  Switch on low bandwidth view
GetKeyboardLayout Function

The GetKeyboardLayout function retrieves the active input locale identifier (formerly called the keyboard layout) for the specified thread. If the idThread parameter is zero, the input locale identifier for the active thread is returned.

Syntax

HKL GetKeyboardLayout(      
    DWORD idThread );

Parameters

idThread
[in] Identifies the thread to query or is zero for the current thread.

Return Value

The return value is the input locale identifier for the thread. The low word contains a Language Identifier for the input language and the high word contains a device handle to the physical layout of the keyboard.

Remarks

The input locale identifier is a broader concept than a keyboard layout, since it can also encompass a speech-to-text converter, an Input Method Editor (IME), or any other form of input.

Since the keyboard layout can be dynamically changed, applications that cache information about the current keyboard layout should process the WM_INPUTLANGCHANGE message to be informed of changes in the input language.

To get the KLID (keyboard layout ID) of the currently active HKL, call the GetKeyboardLayoutName. To find out if a particular KLID is loaded, call GetKeyboardLayoutList, load the keyboard with LoadKeyboardLayout, and then check to see if the HKL is the same as the one already loaded. If not, unload it after.

Function Information

Minimum DLL Versionuser32.dll
HeaderDeclared in Winuser.h, include Windows.h
Import libraryUser32.lib
Minimum operating systems Windows 95, Windows NT 4.0

See Also

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
vb.net syntax      dmex   |   Edit   |   Show History
<DllImport("user32.dll", CharSet:=CharSet.Auto, ExactSpelling:=True)> _
Public Shared Function GetKeyboardLayout(ByVal dwLayout As Integer) As IntPtr
End Function
Tags What's this?: Add a tag
Flag as ContentBug
C# syntax      dmex   |   Edit   |   Show History
[DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
public static extern IntPtr GetKeyboardLayout(int dwLayout);
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker