如何从代码部分访问语言文件中的文本



在Inno Setup中,可以从语言文件中访问文本,例如以下方式(其中CreateDesktopIcon是要查找的文本条目):

[Tasks]
Name: "TaskDesktopIcon"; Description: "{cm:CreateDesktopIcon}"; Flags:

我的问题是如何从Inno Setup脚本的代码部分访问语言文件中的文本?

我尝试了以下方法,但是编译器不接受语法:

[code]
var
  pageAutoLogon: TWizardPage;
procedure CreateAutoLogonPage;
begin 
   pageAutoLogon := CreateCustomPage(wpSelectTasks, "{cm:AutoLogonCredentialsTitle}", "{cm:AutoLogonCredentialsDescription}");
...

任何帮助都是感激的!

您需要调用ExpandConstant(或ExpandConstantEx)函数来计算脚本代码中的常量。例如:

procedure CreateAutoLogonPage;
begin 
  pageAutoLogon := CreateCustomPage(wpSelectTasks, ExpandConstant('{cm:AutoLogonCredentialsTitle}'), ExpandConstant('{cm:AutoLogonCredentialsDescription}'));
  ...
end;

您可以使用CustomMessage()函数从[CustomMessages]部分检索值。

pageAutoLogon := CreateCustomPage(wpSelectTasks, CustomMessage('AutoLogonCredentialsTitle'), CustomMessage('AutoLogonCredentialsDescription'));

对于普通的[Messages],您可以使用SetupMessage()与枚举值之一。

最新更新