如何用api查看用户正在使用什么输入法~~~急!!

jackyhyoung 2004-09-06 08:57:31
如何用api查看用户正在使用什么输入法,各位大侠帮帮忙,,急~!!
...全文
286 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
ryuginka 2004-09-21
  • 打赏
  • 举报
回复
up
limitworld 2004-09-20
  • 打赏
  • 举报
回复
getkeyboardlayout
freedomjim 2004-09-20
  • 打赏
  • 举报
回复
支持楼上
northwolves 2004-09-19
  • 打赏
  • 举报
回复
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
dongle2001 2004-09-19
  • 打赏
  • 举报
回复
用VB在程序中添加切换输入法的功能
思路:,先用GetKeyboardLayoutList 函数来取得所有输入法,然后逐个用ImmIsIME判断是否是中文输入法,如果是的话在用ImmGetDescription
得到输入法的名称,最后选定你需要的输入法用ActivateKeyboardLayout激活它.
源码: Public Declare Function ActivateKeyboardLayout Lib "user32" (ByVal hkl As Long, ByVal flags As Long) As Long
Public Declare Function GetKeyboardLayoutList Lib "user32" (ByVal nBuff As Long, lpList As Long) As Long
Public Declare Function GetKeyboardLayout Lib "user32" (ByVal dwLayout As Long) As Long
Public Declare Function ImmGetDescription Lib "imm32.dll" Alias "ImmGetDescriptionA" (ByVal hkl As Long,
_ByVal lpsz As String, ByVal uBufLen As Long) As Long
Public Declare Function ImmIsIME Lib "imm32.dll" (ByVal hkl As Long) As Long
Public hCurKBDLayout As Long
Public Sub loadsrfz()
Dim buff As String
buff = String(255, 0)
Dim NoOfKBDLayout As Long
Dim BuffLen As Long
Dim retstr As String

hCurKBDLayout = GetKeyboardLayout(0)′取得目前的输入法
NoOfKBDLayout = GetKeyboardLayoutList(25, hkb(0))
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)
If Left(retstr, Len("智能ABC")) = "智能ABC" Then
ActivateKeyboardLayout hkb(I - 1), 0
Exit Sub
End If
End If
Next
End Sub


这是我写的,看看能否帮上你的忙.
supergreenbean 2004-09-06
  • 打赏
  • 举报
回复
试试这篇先

http://www.mf100.com/document/343.shtml

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧