abc_4488 2007-11-22 10:03
如何用api检查任务栏中有多少种输入法
'例1:取得目前所有的输入法
**DeclareFunctionGetKeyboardLayoutListLib"user32"_
(ByValnBuffAsLong,lpListAsLong)AsLong
**DeclareFunctionImmGetDescriptionLib"imm32.dll"_
Alias"ImmGetDescriptionA"(ByValHKLAsLong,_
ByVallpszAsString,ByValuBufLenAsLong)AsLong
**DeclareFunctionImmIsIMELib"imm32.dll"(ByValHKLAsLong)AsLong
**DeclareFunctionActivateKeyboardLayoutLib"user32"_
(ByValHKLAsLong,ByValflagsAsLong)AsLong
**DeclareFunctionGetKeyboardLayoutLib"user32"_
(ByValdwLayoutAsLong)AsLong
**SubForm_Load()
DimNoOfKBDLayoutAsLong,iAsLong,jAsLong
DimhKB(24)AsLong,BuffLenAsLong
DimBuffAsString
DimRetStrAsString
DimRetCountAsLong
Buff=String(255,0)
hCurKBDLayout=GetKeyboardLayout(0)'取得目前keyboardlayout
NoOfKBDLayout=GetKeyboardLayoutList(25,hKB(0))'取得所有输入法的hkeys
Fori=1ToNoOfKBDLayout
IfImmIsIME(hKB(i-1))=1Then'中文输入法
BuffLen=255
RetCount=ImmGetDescription(hKB(i-1),Buff,BuffLen)
RetStr=Left(Buff,RetCount)
Combo1.AddItemRetStr
Else
RetStr="English(American)"'假设我们的win95非Ime者只有English
Combo1.AddItemRetStr'若有其他者,要去取得keyboardLayout
EndIf'Name再去Registry中找其对应的名称
IfhKB(i-1)=hCurKBDLayoutThen
Combo1.Text=RetStr
EndIf
Next
ActivateKeyboardLayouthCurKBDLayout,0'回复原来输入法
EndSub
EndFunction