Inno setup 从[Run]Afterinstall调用[code]中的两个过程

Inno setup 从[Run]Afterinstall调用[code]中的两个过程,inno-setup,Inno Setup,在我的代码部分Pro1和Pro2中有两个过程,Pro1从用户处获取值,Pro2使用该值,因此我希望这些过程以相同的顺序依次执行。 我知道我们可以使用afetinstall从[Run]部分调用过程。我可以用同一顺序使用single Afterinstall调用这两个过程Pro1和Pro2吗 还有一件事,我如何根据代码中编写的条件调用run部分中的特定文件名?这可能吗?我可以多次调用同一文件名吗?我是inno新手,有人能帮我吗。可以为“AfterInstall”参数分配多个函数吗? 不,这是不可能的

在我的代码部分Pro1和Pro2中有两个过程,Pro1从用户处获取值,Pro2使用该值,因此我希望这些过程以相同的顺序依次执行。 我知道我们可以使用afetinstall从[Run]部分调用过程。我可以用同一顺序使用single Afterinstall调用这两个过程Pro1和Pro2吗

还有一件事,我如何根据代码中编写的条件调用run部分中的特定文件名?这可能吗?我可以多次调用同一文件名吗?我是inno新手,有人能帮我吗。

可以为“AfterInstall”参数分配多个函数吗?

不,这是不可能的,但是您可以从一个函数调用另一个函数。因此,您将为参数分配一个函数,并从分配的函数调用另一个函数。在脚本中,它可能如下所示:

[Files]
Source: "MyProg.exe"; DestDir: "{app}"; AfterInstall: AfterInstallProc

[Code]
procedure AfterInstallProc;
begin
  // do something here
  AnotherProcedure;
end;

procedure AnotherProcedure;
begin
  // do something else here
end;
[Run]
Filename: "{code:GetRunEntryFileName}";

[Code]   
function GetRunEntryFileName(Value: string): string;
begin
  // the "SomeCondition" is meant to be a certain variable or statement which
  // evaluates upon your needs; to the Result you'll return the same as you'd
  // write in the script including constants, like e.g. '{app}\MyProg.exe'
  if SomeCondition then
    Result := 'calc.exe'
  else
    Result := 'charmap.exe';
end;
是否可以有条件地为[Run]段条目的“Filename”参数赋值?

是的。您可以声明所谓的,它是一个带有赋值函数的常量,您可以在其中将值返回给参数。在这样的脚本示例中:

[Files]
Source: "MyProg.exe"; DestDir: "{app}"; AfterInstall: AfterInstallProc

[Code]
procedure AfterInstallProc;
begin
  // do something here
  AnotherProcedure;
end;

procedure AnotherProcedure;
begin
  // do something else here
end;
[Run]
Filename: "{code:GetRunEntryFileName}";

[Code]   
function GetRunEntryFileName(Value: string): string;
begin
  // the "SomeCondition" is meant to be a certain variable or statement which
  // evaluates upon your needs; to the Result you'll return the same as you'd
  // write in the script including constants, like e.g. '{app}\MyProg.exe'
  if SomeCondition then
    Result := 'calc.exe'
  else
    Result := 'charmap.exe';
end;
类似的方法可以应用于该节的所有参数,但参数除外,该参数必须在编译时已知

我可以从[运行]部分执行相同的应用程序吗?

是的,你可以。本节不关心您正在执行什么,因此甚至可以有完全相同的条目,或者只是同一应用程序多次的条目。因此,即使这样也有可能:

[Run]
Filename: "{app}\MyProg.exe";
Filename: "{app}\MyProg.exe";
Filename: "{app}\MyProg.exe"; Parameters: "/x"
但这可能只有在您运行某个外部安装程序时才有实际意义,您需要使用不同的命令行参数多次调用该安装程序。我想不出一个理由可以多次以同样的方式执行同一个应用程序