yanhaijun:很遗憾我不能给你高分,虽然我们可能还是本家<br>茶叶蛋很好吃,茶叶蛋大概经常吃。<br><br>下面是我使用的部分代码,增加Windows95没有的设置默认输入法,是商业软件中的哦:<br>uses<br> Menus, Imm, ShellApi, About;<br><br>function ImmGetHotKey(dwHotKeyID: DWord; var uModifiers: UINT;<br> var uVKey: UINT; var hKL: HKL): Boolean; stdcall; external 'Imm32.dll' Name 'ImmGetHotKey';<br><br>function HotKeyToStr(uModifiers, uVKey: UINT): string;<br>var<br> Shift: TShiftState;<br>begin<br> Shift := [];<br> if uModifiers and MOD_ALT <> 0 then Shift := Shift + [ssAlt];<br> if uModifiers and MOD_CONTROL <> 0 then Shift := Shift + [ssCtrl];<br> if uModifiers and MOD_SHIFT <> 0 then Shift := Shift + [ssShift];<br> if uModifiers and MOD_LEFT <> 0 then Shift := Shift + [ssLeft];<br> if uModifiers and MOD_RIGHT <> 0 then Shift := Shift + [ssRight];<br> Result := ShortCutToText(ShortCut(uVKey, Shift));<br>end;<br><br>procedure TSetImeForm.FormCreate(Sender: TObject);<br>const<br> nHKL_LIST = 20;<br>var<br> iImeCount, i, j, iImageIndex: Integer;<br> hImeList: array[1..nHKL_LIST] of HKL;<br> szImeFileName: array[0..MAX_PATH] of Char;<br> szImeName: array[0..254] of Char;<br> hLargeIcon, hSmallIcon: HICON;<br> Icon: TIcon;<br> uModifiers, uVKey: UINT;<br> hIme: HKL;<br> sHotKeys: string;<br>begin<br> ListView.Items.Clear;<br> iImeCount := GetKeyboardLayoutList(nHKL_LIST, hImeList);<br> for i := 1 to iImeCount do<br> if ImmEscape(hImeList, 0, IME_ESC_IME_NAME, @szImeName) > 0 then<br> begin<br> iImageIndex := -1;<br> ImmGetIMEFileName(hImeList, szImeFileName, MAX_PATH);<br> if ExtractIconEx(szImeFileName, 0, hLargeIcon, hSmallIcon, 1) <> 0 then<br> begin<br> Icon := TIcon.Create;<br> Icon.Handle := hSmallIcon;<br> iImageIndex := ImageList.AddIcon(Icon);<br> Icon.Free;<br> end;<br> with ListView.Items.Add do<br> begin<br> Caption := szImeName;<br> ImageIndex := iImageIndex;<br> if Caption = SysIni.ReadString(seUser, idDefaultIme, '五笔型码') then<br> Selected := True;<br> end;<br> end;<br> for i := IME_HOTKEY_DSWITCH_FIRST to IME_HOTKEY_DSWITCH_LAST do<br> if ImmGetHotKey(i, uModifiers, uVKey, hIme) then<br> for j := 1 to iImeCount do<br> if hIme = hImeList[j] then //First Ime is En, and has not name<br> ListView.Items[j - 2].SubItems.Add(HotKeyToStr(uModifiers, uVKey));<br> sHotKeys := '';<br> if ImmGetHotKey(IME_CHOTKEY_IME_NONIME_TOGGLE, uModifiers, uVKey, hIme) then<br> sHotKeys := sHotKeys + '打开关闭输入法' + ' ' + HotKeyToStr(uModifiers, uVKey) + #13;<br> if ImmGetHotKey(IME_CHOTKEY_SYMBOL_TOGGLE, uModifiers, uVKey, hIme) then<br> sHotKeys := sHotKeys + '切换中英文符号' + ' ' + HotKeyToStr(uModifiers, uVKey) + #13;<br> if ImmGetHotKey(IME_CHOTKEY_SHAPE_TOGGLE, uModifiers, uVKey, hIme) then<br> sHotKeys := sHotKeys + '切换全角和半角' + ' ' + HotKeyToStr(uModifiers, uVKey) + #13;<br> HotKeyList.Caption := sHotKeys;<br>end;<br><br>