2017-09-24 59 views
1

当我使用/ DIR命令行开关如何使自定义路径页Inno Setup的/ DIR命令行开关工作

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

指定的路径没有得到用于路径框我的自定义页面:

我使用的是基于Use two/multiple selected directories from custom page in Files section的代码。

这是我正在使用的代码的一个例子。

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

当然它不。您使用自定义控件,Inno安装程序不知道。你的代码示例没有解释“安装”和“便携式”是什么。我们需要[mcve]。 –

+0

这里是:https://paste.ofcode.org/ke9Bam845RSnG8Xubd2x6S – Thebig1825

+0

该代码不显示'GetDir'函数,所以它不是*完成*。而且它几乎不是最小的,因为所有的单选按钮都与问题无关。 –

回答

1

如果你想创新安装的“安装路径”,当包括/DIR= command-line switch处理的标准行为,你有你的自定义路径框链接到一个标准。

因此,尤其是,您必须将WizardForm.DirEdit的初始值复制到您的自定义对话框:

var 
    Page: TInputDirWizardPage; 

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

该解决方案不仅​​,也/LOADINF=处理。

要补充上面的代码,您应该将该值复制回WizardForm.DirEdit。通过这种方式,您可以确保在重新安装/升级时,先前选择的值被重用。这在我对Use two/multiple selected directories from custom page in Files section的回答的第1)部分中显示。


如果以上是因为你安装的复杂的逻辑过于复杂(或不明显)来实现,可以通过编程方式处理自己的​​开关。见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; 

此解决方案显然不处理/LOADINF=。如何处理.inf文件显示在Inno Setup Load defaults for custom installation settings from a file (.inf) for silent installation

此外,使用此解决方案,以前使用的安装路径将不会用于升级/重新安装。如何实现Inno Setup with three destination folders

+0

你没有使用我的答案中的代码。 –

+0

你是什么意思*“存储目录的值”*?你的意思是默认目录?使用'DefaultDirName'。 –

+0

不确定你的意思。但是,是的,这是您需要使用的代码。并且您还需要添加'DefaultDirName'指令来设置默认安装路径,与其他任何安装程序一样。 –

相关问题