inno-setup - Inno Setup:如何将变量从[代码]传递到[运行](或其他部分)

标签 inno-setup pascalscript

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

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


获取用户输入并将其保存到过程InitializeWizard中的变量。
将用户输入传递给[Run]部分中的可执行文件


这是我的代码。

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


谢谢。

最佳答案

您正在寻找scripted constant。请参见以下示例:

[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 - Inno Setup:如何将变量从[代码]传递到[运行](或其他部分),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19299669/

相关文章:

inno-setup - 将 Next 按钮更改为 Install with DisableReadyPage 指令的官方 Inno Setup 代码不起作用

inno-setup - Inno Setup 使目录和文件只读

asp.net - 从永久链接 URL 下载文件,而不是直接的 exe url

installation - 在 Inno Setup 的屏幕中央显示启动画面

installation - 如何在 Inno 设置中更改鼠标光标?

inno-setup - 如何在静默模式下编译 Innosetup 脚本?

service - Inno Setup - 在文件复制之前正确停止服务

pascalscript - 创建脚本以重命名以 ".txt"结尾的帮助文件主题

inno-setup - 下次执行 Inno Setup 制作的安装程序时,恢复之前在自定义页面上输入的数据

inno-setup - 在 Inno Setup 中使用 SAPI 对象