[英]How to save to Windows registry the language chosen when setup.exe (from INNO 5.5.4) is executed?
I have a Build (*.iss) file for INNO that gives the user the possibility of choosing between 4 languages when the setup.exe is executed. 我有一个用于INNO的构建(* .iss)文件,该文件使用户可以在执行setup.exe时在4种语言之间进行选择。 I would like the language chosen by the user to be saved in the Windows registry (or in a file where the setup.exe is located).
我希望将用户选择的语言保存在Windows注册表中(或setup.exe所在的文件中)。 This would be used as input to the installed program.
这将用作已安装程序的输入。 The installed program will then dynamically change the language used for the menu items/messages to the language chosen by the user.
然后,已安装的程序将把菜单项/消息所使用的语言动态地更改为用户选择的语言。
How can I this task be accomplished in the INNO *.iss file? 我如何在INNO * .iss文件中完成此任务?
You can store the value given by the {language}
constant. 您可以存储
{language}
常量给定的值。 It returns the selected language identifier name (the name specified by the Name
parameter of the [Languages]
section entry). 它返回选定的语言标识符名称(由
[Languages]
节条目的Name
参数指定的Name
)。 For instance, the following script will store either en
or nl
value (depending on which language the user selects) to the specified registry key: 例如,以下脚本会将
en
或nl
值(取决于用户选择的语言)存储到指定的注册表项:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName=My Program
[Languages]
Name: "en"; MessagesFile: "compiler:Default.isl"
Name: "nl"; MessagesFile: "compiler:Languages\Dutch.isl"
[Registry]
Root: HKLM; Subkey: "Software\My Company\My Program\Settings"; ValueType: string; ValueName: "Language"; ValueData: "{language}"
In a code you can query the ActiveLanguage
function, which returns the same language identifier as the {language}
constant. 在代码中,您可以查询
ActiveLanguage
函数,该函数返回与{language}
常量相同的语言标识符。 To store this identifier into a text file in the form you've mentioned after the installation is done, you can use the following code: 要将标识符以安装后提到的形式存储到文本文件中,可以使用以下代码:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName=My Program
[Languages]
Name: "en"; MessagesFile: "compiler:Default.isl"
Name: "de"; MessagesFile: "compiler:Languages\German.isl"
[Code]
procedure CurStepChanged(CurStep: TSetupStep);
var
S: string;
begin
if CurStep = ssPostInstall then
begin
S := Format('language = "%s"', [ActiveLanguage]);
SaveStringToFile('C:\File.txt', S, False);
end;
end;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.