📄 ime.pas
字号:
unit ime;
interface
uses SysUtils, WinTypes, WinProcs, Dialogs;
type
// 必要的类型声明
TDateNTime = record
wYear, wMonth, wDay: word;
wHour, wMin, wSec: word;
end;
TImePro = record
hWndIme: HWnd; { IME handle }
dtInstDate: tDateNTime; { Date and time of installation }
wVersion: word; { the version of IME }
szDescription: array[0..49] of byte; { Description of IME module}
szName: array[0..79] of byte; { Module name of the IME }
szOptions: array[0..29] of byte; { options of IME at startup}
fEnable: boolean; { IME status; True=activated,False=deactivated }
end;
pTImePro = ^TImePro;
function SetIme(const sImeFileName: string): boolean; far;
implementation
// 调用 winnls.dll export 函数的声明
function ImpSetIme(hWndIme: HWND; lpImePro: pTImePro): boolean;far; external 'winnls.dll';
// --------------------------------------------------
// SetIme(const sImeFileName: string): boolean;// 切换到某一特定的输入法
// 传入参数: sImeFileName--输入法 IME 文件名, 例: winpy.ime; 若为空字串: 英数输入法
// 传回值: True--切换成功, False--失败
function SetIme(const sImeFileName: string): boolean;
var pImePro: pTImePro;
MaxAvail: Integer;
begin
Result := False;
if MaxAvail < SizeOf(TImePro) then
begin
MessageDlg('内存不足', mtWarning, [mbOk], 0);
Exit;
end
else
begin
New(pImePro);
try
if sImeFileName = '' then (* 空字串, 还原到英数输入法 *)
pImePro^.szName[0] := 0
else
StrPCopy(@pImePro^.szName, sImeFileName);
Result := ImpSetIme(0, pImePro); (* 调用 ImpSetIme *)
finally
Dispose(pImePro);
end; { of try }
end;
end; { of SetIme }
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -