包括要使用Inno Setup 6.1.1 Beta下载到“就绪”页面的文件摘要?

问题描述

使用 Inno Download Plugin 我有一个代码注册要下载的文件列表,并将该列表同时添加“ Ready” 页面备忘录中: Building memo text for Inno Download Plugin

修改代码以使其可用于Inno Setup 6.1.1下载页面,而不是IDP:

procedure AddFileForDownload(Url,FileName: string);
begin
    DownloadPage.Add(Url,FileName,'');
    FilesTodownload := FilesTodownload + '      ' + ExtractFileName(FileName) + #13#10;
    Log('File to download: ' + Url);
end;

然后我像这样调整NextButtonClick

function NextButtonClick(CurPageID: integer): boolean;
begin
    Result := True;
 
    if (CurPageID = wpReady) then
    begin
        DownloadPage.Clear;
        if (dotNetNeeded) then begin
            { We need to download the 4.6.2 setup from the Microsoft Website }
            dotNetRedistPath := ExpandConstant('{tmp}\NDP451-KB2858728-x86-x64-AllOS-ENU.exe');
            AddFileForDownload(dotnetRedistURL,'NDP451-KB2858728-x86-x64-AllOS-ENU.exe');
        end;

        if (bVcRedist64BitNeeded) then
        begin
            { We need to download the 64 Bit VC Redistributable from the Microsoft Website }
            vcRedist64BitPath := ExpandConstant('{tmp}\vc_redist.x64.exe');
            AddFileForDownload(vcRedist64BitURL,'vc_redist.x64.exe');
        end;

        if (bVcRedist32BitNeeded) then
        begin
            { We need to download the 32 Bit VC Redistributable from the Microsoft Website }
            vcRedist32BitPath := ExpandConstant('{tmp}\vc_redist.x86.exe');
            AddFileForDownload(vcRedist32BitURL,'vc_redist.x86.exe');
        end;

        if (WizardisTaskSelected('downloadhelp')) then
            AddFileForDownload('{#HelpDocSetupURL}','HelpDocSetup.exe');

        DownloadPage.Show;
        try
          try
            DownloadPage.Download;
            Result := True;
          except
            SuppressibleMsgBox(AddPeriod(GetExceptionMessage),mbCriticalError,MB_OK,IDOK);
            Result := False;
          end;
        finally
          DownloadPage.Hide;
        end;
    end;
end;

我运行了安装程序,并选中了向导选项以下载帮助文档,但仅显示 Ready (就绪)页面

Installer

添加下载部分。这个怎么可能?当我单击下一步时,它会继续进入下一页以下载文件

我为FilesTodownload添加了一些额外的日志记录,这很有趣:

2020-11-01 11:44:22.409   UpdateReadyMemo FiletoDownload: 
2020-11-01 11:44:25.671   File to download: https://www.publictalksoftware.co.uk/downloads/MSAHelpDocumentationSetup.exe
2020-11-01 11:44:25.671   FiletoDownload:       HelpDocSetup.exe

在填充变量之前,在之前调用UpdateReadyMemo方法。糊涂了!

解决方法

最初我有点困惑。因为问题很明显。当您单击“就绪” 页面上的“安装” 按钮时,将执行您的代码。因此很明显,只有在“就绪” 页面显示之后。

您必须提前致电AddFileForDownload。也许要NextButtonClick(wpSelectTasks)

function NextButtonClick(CurPageID: integer): boolean;
begin
  Result := True;

  if (CurPageID = wpSelectTasks) then
  begin
    DownloadPage.Clear;
    if (dotNetNeeded) then
    begin
      { We need to download the 4.6.2 setup from the Microsoft Website }
      dotNetRedistPath :=
        ExpandConstant('{tmp}\NDP451-KB2858728-x86-x64-AllOS-ENU.exe');
      AddFileForDownload(dotnetRedistURL,'NDP451-KB2858728-x86-x64-AllOS-ENU.exe');
    end;

    if (bVcRedist64BitNeeded) then
    begin
      { We need to download the 64 Bit VC Redistributable from the Microsoft Website }
      vcRedist64BitPath := ExpandConstant('{tmp}\vc_redist.x64.exe');
      AddFileForDownload(vcRedist64BitURL,'vc_redist.x64.exe');
    end;

    if (bVcRedist32BitNeeded) then
    begin
      { We need to download the 32 Bit VC Redistributable from the Microsoft Website }
      vcRedist32BitPath := ExpandConstant('{tmp}\vc_redist.x86.exe');
      AddFileForDownload(vcRedist32BitURL,'vc_redist.x86.exe');
    end;

    if (WizardIsTaskSelected('downloadhelp')) then
      AddFileForDownload('{#HelpDocSetupURL}','HelpDocSetup.exe');
  end
    else
  if (CurPageID = wpReady) then
  begin
    DownloadPage.Show;
    try
      try
        DownloadPage.Download;
        Result := True;
      except
        SuppressibleMsgBox(
          AddPeriod(GetExceptionMessage),mbCriticalError,MB_OK,IDOK);
        Result := False;
      end;
    finally
      DownloadPage.Hide;
    end;
  end;
end;

(未经测试)