faressoft
faressoft

Reputation: 19641

How to check the current keyboard's language using vb6?

How to check the current keyboard's language using vb6 ?

IF ("Is it the English language") Then
   Msgbox "EN"
End IF

alt text

Upvotes: 1

Views: 2283

Answers (2)

wqw
wqw

Reputation: 11991

I'm using this not very tested snippet

Private Const LOCALE_SISO639LANGNAME        As Long = &H59

Private Declare Function GetKeyboardLayout Lib "user32" (ByVal dwLayout As Long) As Long
Private Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long

Private Sub Command1_Click()
    MsgBox pvGetUserLocaleInfo(GetKeyboardLayout(0&) And &HFFFF&, LOCALE_SISO639LANGNAME)
End Sub

Private Function pvGetUserLocaleInfo(ByVal dwLocaleID As Long, ByVal dwLCType As Long) As String
   Dim sReturn          As String
   Dim nSize            As Long

   nSize = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, Len(sReturn))
   If nSize > 0 Then
      sReturn = Space$(nSize)
      nSize = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, Len(sReturn))
      If nSize > 0 Then
         pvGetUserLocaleInfo = Left$(sReturn, nSize - 1)
      End If
   End If
End Function

Upvotes: 3

Eugene
Eugene

Reputation: 11535

I believe its GetKeyboardLayoutName.

Upvotes: 0

Related Questions