Inno Setup - 避免显示子安装程序的文件名

时间:2017-03-01 11:57:59

标签: inno-setup

我正在尝试使用Inno Setup - How to hide certain filenames while installing? (FilenameLabel)

中的想法
  

唯一可靠的解决方案是使用[Files]部分避免安装您不想显示的文件。请使用代码安装它们。使用ExtractTemporaryFileFileCopy功能

但是我要隐藏的文件正在[Run]部分中使用:

[Files]
Source: "_Redist\DXWebSetup.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall

[Run]
Filename: "{tmp}\DXWebSetup.exe"; Components: DirectX; StatusMsg: "Installing DirectX..."; \
  BeforeInstall: StartWaitingForDirectXWindow; AfterInstall: StopWaitingForDirectXWindow

如何使用[Files]部分,ExtractTemporaryFileFileCopy功能隐藏(在文件管理标签中安装时)?

1 个答案:

答案 0 :(得分:1)

最简单的方法是放弃标准的[Files][Run]部分,并在CurStepChanged event fuction中自行编码:

[Files]
Source: "dxwebsetup.exe"; Flags: dontcopy

[Code]

procedure CurStepChanged(CurStep: TSetupStep);
var
  ProgressPage: TOutputProgressWizardPage;
  ResultCode: Integer;
begin
  if CurStep = ssInstall then { or maybe ssPostInstall }
  begin
    if IsComponentSelected('DirectX') then
    begin
      ProgressPage := CreateOutputProgressPage('Installing prerequsities', '');
      ProgressPage.SetText('Installing DirectX...', '');
      ProgressPage.Show;
      try
        ExtractTemporaryFile('dxwebsetup.exe');
        StartWaitingForDirectXWindow;
        Exec(ExpandConstant('{tmp}\dxwebsetup.exe'), '', '', SW_SHOW,
             ewWaitUntilTerminated, ResultCode);
      finally
        StopWaitingForDirectXWindow;
        ProgressPage.Hide;
      end;
    end;
  end;
end;

这甚至让您有机会检查子安装程序的结果。你可以,例如当子安装程序失败或被取消时,防止安装继续。

然后,使用PrepareToInstall而不是CurStepChanged更容易。

另一种选择是在提取子安装程序时显示自定义标签 见Inno Setup - How to create a personalized FilenameLabel with the names I want?