|
||||
GetKeyboardLayoutNameCategory: KeyboardHits: 3078 Rating: (2.92) votes 674
Rate: 1-star 2-stars 3-stars 4-stars 5-stars
API Explanation
The GetKeyboardLayoutName function retrieves the name of the active keyboard layout. Parameter Information Declare Function GetKeyboardLayoutName Lib "user32" Alias "GetKeyboardLayoutNameA" (ByVal pwszKLID As String) As Long · pwszKLID Points to the buffer of at least KL_NAMELENGTH characters that is to receive the name of the keyboard layout, including the NULL terminator. This will be a copy of the string provided to the LoadKeyboardLayout function, unless layout substitution took place. If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError.
Code
Const KL_NAMELENGTH = 9
Const KT_TYPE = 0 Const KT_SUBTYPE = 1 Const KT_FUNCTIONKEYS = 2 Private Declare Function GetKeyboardLayoutName Lib "user32" Alias "GetKeyboardLayoutNameA" _ (ByVal pwszKLID As String) As Long Private Declare Function GetKeyboardType Lib "user32" (ByVal nTypeFlag As Long) As Long Private Sub Form_Paint() Dim strName As String 'Clear the form Me.Cls 'Create a buffer strName = String(KL_NAMELENGTH, 0) 'Get the keyboard layout name GetKeyboardLayoutName strName Me.Print "Keyboard layout name: " + strName Select Case GetKeyboardType(KT_TYPE) Case 1 Me.Print "Keyboard type: IBM PC/XT or compatible (83-key) keyboard" Case 2 Me.Print "Keyboard type: Olivetti "ICO" (102-key) keyboard" Case 3 Me.Print "Keyboard type: IBM PC/AT (84-key) or similar keyboard" Case 4 Me.Print "Keyboard type: IBM enhanced (101- or 102-key) keyboard" Case 5 Me.Print "Keyboard type: Nokia 1050 and similar keyboards" Case 6 Me.Print "Keyboard type: Nokia 9140 and similar keyboards" Case 7 Me.Print "Keyboard type: Japanese keyboard" Case Else7 Me.Print "Keyboard type: Unknown" End Select Select Case GetKeyboardType(KT_FUNCTIONKEYS) Case 1 Me.Print "Number of function keys: 10" Case 2 Me.Print "Number of function keys: 12 (sometimes 18)" Case 3 Me.Print "Number of function keys: 10" Case 4 Me.Print "Number of function keys: 12" Case 5 Me.Print "Number of function keys: 10" Case 6 Me.Print "Number of function keys: 24" Case 7 Me.Print "Number of function keys: Hardware dependent and specified by the OEM" Case Else Me.Print "Number of function keys: Unknown" End Select End Sub |