Private Declare Function ImmGetDescription Lib "imm32.dll" _
Alias "ImmGetDescriptionA" (ByVal hkl As Long, _
ByVal lpsz As String, ByVal uBufLen As Long) As Long
Private Declare Function ImmIsIME Lib "imm32.dll" (ByVal hkl As Long) As Long
Private Declare Function ActivateKeyboardLayout Lib "user32" _
(ByVal hkl As Long, ByVal flags As Long) As Long
Private Declare Function GetKeyboardLayout Lib "user32" (ByVal dwLayout As Long) As Long
Private Sub Form_Load()
MsgBox getlayout, vbInformation, "当前输入法"
End Sub
Function getlayout() As String
Dim buff As Long
getlayout = "英文输入法"
buff = GetKeyboardLayout(0) '取得目前的输入法
If ImmIsIME(buff) = 1 Then '中文输入法
getlayout = Space(255)
ImmGetDescription buff, getlayout, Len(getlayout)
End If
End Function
激活某种输入法可以用ActivateKeyboardLayout