Inno Setup:如何将变量从[代码]传递到[运行](或其他部分) [英] Inno Setup: How to pass variable from [Code] to [Run] (or other section)

查看:188
本文介绍了Inno Setup:如何将变量从[代码]传递到[运行](或其他部分)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Inno Setup中将变量从[Code]部分传递给[Run]部分中的参数?

How can I pass a variable from [Code] section to parameters in [Run] section in Inno Setup?

基本上,我想执行以下操作.

Basically, I want to do the following.

  1. 获取用户输入并将其保存到过程InitializeWizard中的变量.
  2. 将用户输入传递到[Run]部分中的可执行文件
  1. Get and save user input to a variable in a procedure InitializeWizard.
  2. Pass the user input to an executable in [Run] section

这是我的代码.

[Run]
Filename: "someProgram.exe"; Parameters: ??userInput??

[Code]
procedure InitializeWizard;
var 
  ConfigPage: TInputQueryWizardPage;
  UserInput: String;
begin
  { Create the page }
  ConfigPage :=
    CreateInputQueryPage(
      wpWelcome, 'User input', 'User input',
      'Please specify the following information, then click Next.');

  { Add items (False means it's not a password edit) }
  ConfigPage.Add('Input here:', False);
  { Set initial values (optional) }
  ConfigPage.Values[0] := ExpandConstant('hello');
  { Read values into variables }
  UserInput := ConfigPage.Values[0];
end;

谢谢.

推荐答案

您正在寻找脚本常量.请参见以下示例:

You're looking for the scripted constant. See the following example:

[Run]
Filename: "SomeProgram.exe"; Parameters: {code:GetParams}

[Code]
var
  ConfigPage: TInputQueryWizardPage;

function GetParams(Value: string): string;
begin
  Result := ConfigPage.Values[0];
end;

procedure InitializeWizard;
begin
  { Create the page }
  ConfigPage :=
    CreateInputQueryPage(
      wpWelcome, 'User input', 'User input',
      'Please specify the following information, then click Next.');
  { Add items (False means it's not a password edit) }
  ConfigPage.Add('Input here:', False);
  { Set initial values (optional) }
  ConfigPage.Values[0] := ExpandConstant('hello');
end;

这篇关于Inno Setup:如何将变量从[代码]传递到[运行](或其他部分)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆