切换输入法<br>Uses ...,Shellapi <br>. <br>. <br>. <br>function MakeKeyboardLayout(PrimaryLanguage, SubLanguage: Integer): String; <br>begin <br> Result := IntToHex(PrimaryLanguage or (SubLanguage shl 10), <br> KL_NAMELENGTH - 1); <br>end; <br><br>function FarsiKeyboardLayout: String; <br>begin <br> Result := MakeKeyboardLayout(LANG_FARSI,SUBLANG_DEFAULT); <br>end; <br><br>function EnglishKeyboardLayout: String; <br>begin <br> Result := MakeKeyboardLayout(LANG_ENGLISH, SUBLANG_DEFAULT); <br>end; <br><br>procedure TForm1.FarsiKeyboard(Sender: TObject); <br>begin <br> if LoadKeyboardLayout(PChar(FarsiKeyboardLayout), <br> KLF_ACTIVATE or KLF_REORDER) = 0 then <br> MessageDlg(ErrMsgFarsiKeyboard, mtError, [mbOK], 0); <br>end; <br><br>procedure TForm1.EnglishKeyboard(Sender: TObject); <br>begin <br> LoadKeyboardLayout(PChar(EnglishKeyboardLayout), <br> KLF_ACTIVATE or KLF_REORDER); <br>end; <br><br>procedure TForm1.NextKeyboardActionExecute(Sender: TObject); <br>begin <br> ActivateKeyboardLayout(HKL_NEXT, 0);//在语言之间切换<br>end;