我有功能
procedure bgGetKeyboardLayoutList(List: TStrings);
var
AList : array [0..50] of Hkl;
AklName: array [0..255] of Char;
i: Longint;
begin
List.Clear;
for i := 0 to GetKeyboardLayoutList(SizeOf(AList), AList) - 1 do
begin
GetLocaleInfo(LoWord(AList[i]), LOCALE_SLANGUAGE, AklName, SizeOf(
AklName));
List.AddObject(AklName, Pointer(AList[i]));
end;
end;
该函数被调用
procedure TDefaultInputMethod.Scan;
begin
bgGetKeyboardLayoutList(FSL);
end;
但是当我尝试在相反的方向使用 SetLocaleInfo 时,我没有成功代码:
procedure TDefaultInputMethod.SetAsDefault(index: integer);
begin
ActivateKeyboardLayout(Hkl(FSL.Objects[index]), 0); //this line works
if SetLocaleInfo(LoWord(FSL.Objects[index]), LOCALE_SLANGUAGE, PChar(FSL[index])) then
ShowMessage('Uspeh')
else
begin
ShowMessage(IntToStr(GetLastError));
end;
end;
GetLasrError 返回 1004
在此先感谢博扬