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

Including a summary of the files to download with Inno Setup 6.1.1 beta to Ready page?

使用 Inno 下载插件 我有一个代码可以注册要下载的文件列表并将列表添加到 “准备就绪” 页面同时备忘:

我修改了代码以使用 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 页面仅显示:

未添加 下载 部分。怎么可能?当我单击 下一步 时,它会继续到下一页下载文件。

我为 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;

(未测试)