1

With Inno Download Plugin I had a code that registers a list of files to download and adds the list to "Ready" page memo at the same time: Building memo text for Inno Download Plugin

I have modified the code to work with Inno Setup 6.1.1 download page, instead of IDP:

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

Then I adjusted NextButtonClick like this:

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;

I ran the installer, and checked the wizard option to download the help documentation, and yet the Ready page displays only:

Installer

The Download section is not being added. How can that be? When I click Next it does continue to the next page to download the file.

I added some extra logging for FilesToDownload and it is interesting:

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

The UpdateReadyMemo method is being called before we populate the variable. Confused!

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164

1 Answers1

1

I got confused a bit initially. Because the issue is obvious. Your code executes when you click "Install" button on the "Ready" page. So obviously only after the "Ready" page shows.

You have to call the AddFileForDownload earlier. Maybe to 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;

(untested)

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992