我有功能
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;
Run Code Online (Sandbox Code Playgroud)
该函数被调用
procedure TDefaultInputMethod.Scan;
begin
bgGetKeyboardLayoutList(FSL);
end;
Run Code Online (Sandbox Code Playgroud)
但是当我尝试相反的方向使用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;
Run Code Online (Sandbox Code Playgroud)
GetLasrError返回1004
在此先感谢Bojan
ShowMessage(SysErrorMessage(GetLastError));表示1004是Invalid flags.
根据SetLocaleInfoMSDN 上的文档,这对应于ERROR_INVALID_FLAGS,并且这是由传递给函数的无效值引起的.
问题在于第二个参数(LOCALE_SLANGUAGE),根据文档,它再次不是可以使用的值之一SetLocaleInfo.它只能用于GetLocaleInfo检索信息.(参见Constants Used in the LCType Parameter of GetLocaleInfo, GetLocaleInfoEx, and SetLocaleInfo该页标题开头的部分.)
| 归档时间: |
|
| 查看次数: |
1114 次 |
| 最近记录: |