设置输入法
procedure TForm1.SetMyIme(ImeName: string);
var
i: integer;
HandleToSet: HKL;
begin
if not SysLocale.FarEast then
Exit;
if ImeName <> ' ' then begin
if (AnsiCompareText(ImeName, Screen.DefaultIme) <> 0) and (Screen.Imes.Count <> 0) then begin
HandletoSet := Screen.DefaultKbLayout;
i := Screen.Imes.IndexOf(ImeName);
if i >= 0 then
HandletoSet := HKL(Screen.Imes.Objects);
ActivateKeyboardLayout(HandleToSet, KLF_ACTIVATE);
end;
end;
end;
得到当前输入法名称:
const MAX_PATH=?
function TForm1.GetImeFileName: string;
var
szImeFileName: array[0..MAX_PATH] of char;
begin
if ImmGetIMEFileName(myhkl, szImeFileName, MAX_PATH) <> 0 then
Result := AnsiUpperCase(StrPas(szImeFileName))
else
Result := '';
end;