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

前端 未结 2 1520
一个人的身影
一个人的身影 2021-01-23 19:00

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

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

相关标签:
2条回答
  • 2021-01-23 19:20

    I believe its GetKeyboardLayoutName.

    0 讨论(0)
  • 2021-01-23 19:30

    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
    
    0 讨论(0)
提交回复
热议问题