# Re: 请问要如何侦测有无安装何种输入法(如呒虾米)?

Posted by 小v on July 31, 1999 at 09:46:38:

In Reply to: Re: 请问要如何侦测有无安装何种输入法(如呒虾米)? posted by 阿志 on July 30, 1999 at 22:02:58:

: 如题~

在FORM放一个ComboBox然后RUN以下程式:

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 No As Long, i As Long, j As Long, OLD As Long
Dim hKB(24) As Long, bufflen As Long
Dim buff As String, RetStr As String, RetCount As Long
buff = String(255, 0)
OLD = GetKeyboardLayout(0)
No = GetKeyboardLayoutList(25, hKB(0))
For i = 1 To No
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)"
Combo1.AddItem RetStr
End If
If hKB(i - 1) = OLD Then
Combo1.Text = RetStr
End If
Next
ActivateKeyboardLayout OLD, 0
End Sub

Follow Ups: