简体   繁体   English

如何将执行setup.exe(来自INNO 5.5.4)时选择的语言保存到Windows注册表?

[英]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: 例如,以下脚本会将ennl值(取决于用户选择的语言)存储到指定的注册表项:

[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.

相关问题 在 Inno Setup 中如何将用户输入保存到注册表? - In Inno Setup how to save user inputs to registry? Inno Setup运行setup.exe时修改app.config文件 - Inno Setup Modify app.config file when you run setup.exe 在 Inno Setup 安装程序中选择应用程序语言并将其保存到注册表 - Select application language and save it to registry in Inno Setup installer 在Windows XP上,inno setup.exe失败,浮点除零 - inno setup.exe fails with Floating point division by zero on Windows XP Inno Setup-Setup.exe在本地运行,但不能下载 - Inno Setup - Setup.exe works locally, but not as a download Windows 7下的Inno Setup 5.5.4(a)错误为“无法导入dll” - Inno Setup 5.5.4(a) under Windows 7 with mistake “cannot import dll” 使用inno setup注册Windows注册表文件 - register windows registry file using inno setup 运行由Inno Setup创建的Setup.exe并获取“ ...'“ isxdl.dll'未找到。”错误 - Running Setup.exe created by Inno Setup and get “… '”isxdl.dll' was not found." error 使用 Inno Setup 安装 mod/plugin 时,如何从注册表获取目标游戏/应用程序的安装路径? - How to get path of installation of target game/application from registry when installing mod/plugin using Inno Setup? Inno Setup设置Setup.exe的创建日期和修改日期相同 - Inno Setup set Setup.exe create date and modified date the same
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM