如何使用VB 6检查当前键盘的语言总是时间?

时间:2012-05-22 13:16:46

标签: vb6

  

可能重复:
  How to check the current keyboard's language using vb6?

如何使用VB 6始终检查当前键盘的语言?

Private Sub Timer1_Timer() 
IF (language = EN) Then 
label1.caption = EN 
else ...... 
End IF
End Sub

1 个答案:

答案 0 :(得分:1)

使用WMI可以非常轻松地完成:

功能

Public Function GetPropValue(PropName$) As String
    Dim result$
    result = ""
    Set WMIObjectSet = GetObject("winmgmts:\\.\root\CIMV2").ExecQuery("SELECT *FROM Win32_OperatingSystem")
    For Each WMIObject In WMIObjectSet
        If result <> "" Then
            Exit For
        Else
            For Each WMIProperty In WMIObject.Properties_
                If WMIProperty.Name = PropName Then
                    result = WMIProperty.Value
                    Exit For
                End If
            Next
        End If
    Next
    GetPropValue = result
End Function

可以被称为:

GetPropValue("OSLanguage")
1033

现在必须使用代码页编号检查值。有关详细信息,请访问here

或者

Private Declare Function GetThreadLocale Lib "kernel32" () As Long

Private Sub Timer1_Timer() 
IF (GetThreadLocale = 1033) Then 
    label1.caption="EN"
else
    'check other values
End IF
End Sub