如何使用vb6检查当前键盘的语言?

时间:2011-01-02 22:08:28

标签: vb6 localization

如何使用vb6检查当前键盘的语言?

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

alt text

2 个答案:

答案 0 :(得分:2)

我正在使用这个非常经过测试的代码段

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

答案 1 :(得分:0)

我相信它的GetKeyboardLayoutName