如何使Inno Setup/DIR命令行开关与自定义路径页面一起使用 [英] How to make Inno Setup /DIR command line switch work with custom path page

查看:162
本文介绍了如何使Inno Setup/DIR命令行开关与自定义路径页面一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用/DIR命令行开关

"Mysoft.exe" /VERYSILENT /installerbusiness /DIR="C:\Program Files (x86)"

指定的路径未用于我的自定义页面上的路径框:

我正在使用基于在文件"部分的自定义页面中使用两个/多个选定目录的代码.

>

这是我正在使用的代码的示例.

 [Code]

var
  Install: TInputDirWizardPage;

procedure InitializeWizard();
begin
  Install :=
    CreateInputDirPage(
      wpSelectDir, CustomMessage('Readyinstall'), 
      CustomMessage('Readyinstallpc'), #13#10#13#10 + CustomMessage('Tocontinuet'),
      True, 'Mysoft');

  Install.Add(CustomMessage('DestFolder'));

  Install.Values[0] := ('C:\Program Files\Mysoft');
  { ... }
end;
 

解决方案

如果您想要Inno Setup的安装路径"的标准行为,其中包括对 var Page: TInputDirWizardPage; procedure InitializeWizard(); begin ... Page := CreateInputDirPage(...); Page.Add(...); Page.Values[0] := WizardForm.DirEdit.Text; end;

此解决方案不仅可以处理/DIR=,还可以处理 .

为补充上面的代码,您应该将值复制回WizardForm.DirEdit.这样,您可以确保在重新安装/升级时,可以重新使用先前选择的值.这显示在我对在文件"部分的自定义页面中使用两个/多个选定目录的答案的第1点).. >


如果由于安装程序的逻辑复杂而导致上述操作过于复杂(或不太明显),则您可以自己以编程方式处理/DIR=开关.请参见通过命令行设置Inno Setup自定义页面字段的值.

 procedure InitializeWizard();
var
  DirSwitchValue: string;
begin
  Install := ...;

  Install.Add(...);

  DirSwitchValue := ExpandConstant('{param:DIR}');
  if DirSwitchValue <> '' then
  begin
    Install.Values[0] := DirSwitchValue;
  end
    else
  begin
    Install.Values[0] := ExpandConstant('{pf}\Mysoft');
  end;
end;
 

此解决方案显然无法处理/LOADINF=. Inno Setup中显示了如何处理.inf文件的方法.从文件(.inf)加载自定义安装设置的默认设置以进行静默安装.

此外,使用此解决方案,以前使用的安装路径将不会用于升级/重新安装. 带有三个目标文件夹的Inno设置中显示的实现方式.

When I use /DIR command line switch

"Mysoft.exe" /VERYSILENT /installerbusiness /DIR="C:\Program Files (x86)"

The specified path does not get used for path box on my custom page :

I'm using code based on Use two/multiple selected directories from custom page in Files section.

This is an example of the code I'm using.

[Code]

var
  Install: TInputDirWizardPage;

procedure InitializeWizard();
begin
  Install :=
    CreateInputDirPage(
      wpSelectDir, CustomMessage('Readyinstall'), 
      CustomMessage('Readyinstallpc'), #13#10#13#10 + CustomMessage('Tocontinuet'),
      True, 'Mysoft');

  Install.Add(CustomMessage('DestFolder'));

  Install.Values[0] := ('C:\Program Files\Mysoft');
  { ... }
end;

解决方案

If you want the standard behavior of "installation path" of Inno Setup, which includes the processing of /DIR= command-line switch, you have to link your custom path box to the standard one.

So particularly, you have to copy the initial value of the WizardForm.DirEdit to your custom box:

var
  Page: TInputDirWizardPage;

procedure InitializeWizard();
begin
  ...
  Page := CreateInputDirPage(...);
  Page.Add(...);
  Page.Values[0] := WizardForm.DirEdit.Text;
end;

This solution handles not only /DIR=, but also /LOADINF=.

To complement the code above, you should copy the value back to WizardForm.DirEdit. This way you make sure that on re-install/upgrade, the previously selected value is reused. This is shown in point 1) of my answer to Use two/multiple selected directories from custom page in Files section.


If the above is too complicated (or not obvious) to implement, because of a complex logic of your installer, you can handle the /DIR= switch programmatically yourself. See Setting value of Inno Setup custom page field from command-line.

procedure InitializeWizard();
var
  DirSwitchValue: string;
begin
  Install := ...;

  Install.Add(...);

  DirSwitchValue := ExpandConstant('{param:DIR}');
  if DirSwitchValue <> '' then
  begin
    Install.Values[0] := DirSwitchValue;
  end
    else
  begin
    Install.Values[0] := ExpandConstant('{pf}\Mysoft');
  end;
end;

This solution obviously does not handle /LOADINF=. How to process .inf files is shown in Inno Setup Load defaults for custom installation settings from a file (.inf) for silent installation.

Also, with this solution, the previously used installation path won't be used for upgrades/re-installs. How to implement that is shown in Inno Setup with three destination folders.

这篇关于如何使Inno Setup/DIR命令行开关与自定义路径页面一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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