vb 获取windows中的输入法列表
发布网友
发布时间:2022-05-17 18:30
我来回答
共2个回答
热心网友
时间:2023-11-01 22:44
'运行下面程序后下拉框控件combo1中显示的系统的所有输入法的列表。
Private Declare Function GetKeyboardLayoutList Lib "user32" (ByVal nBuff As Long, lpList As Long) As Long
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()
Dim NoOfKBDLayout As Long, i As Long, j As Long, hCurKBDLayout As Long
Dim hKB(24) As Long, BuffLen As Long
Dim Buff As String
Dim RetStr As String
Dim RetCount As Long
Buff = String(255, 0)
hCurKBDLayout = GetKeyboardLayout(0) '取得目前keyboardlayout
NoOfKBDLayout = GetKeyboardLayoutList(25, hKB(0)) '取得所有输入法的 hkeys
For i = 1 To NoOfKBDLayout
If ImmIsIME(hKB(i - 1)) = 1 Then '中文输入法
BuffLen = 255
RetCount = ImmGetDescription(hKB(i - 1), Buff, BuffLen)
RetStr = Left(Buff, RetCount)
Combo1.AddItem RetStr
Else
RetStr = "English (American)" '假设我们的win95非Ime者只有 English
Combo1.AddItem RetStr '若有其他者,要去取得keyboardLayout
End If 'Name 再去 Registry 中找其对应的名称
If hKB(i - 1) = hCurKBDLayout Then
Combo1.Text = RetStr
End If
Next i
ActivateKeyboardLayout hCurKBDLayout, 0 '恢复原来输入法
End Sub
'thanks for your praise,^^!
热心网友
时间:2023-11-01 22:44
楼上的 真会抄袭 ....
楼上 的 你的代码是 02年的吧..