使用 IDP 根据第一次下载的内容下载其他文件

Download additional files based on contents of first download using IDP

想要使用 Inno Download Plugin (IDP) 根据第一次下载的内容下载文件。怎么做?

这是我的代码

[Code]
procedure InitializeWizard();
var
  line: string;
  line2: string;
  url: string;
  appname: string;
begin
  idpAddFile('http://download.website.com/files.txt', ExpandConstant('{tmp}\files.txt'));
  idpDownloadAfter(wpReady);
  TryGetFileLine(expandConstant('{tmp}\files.txt'), 0, line);
  TryGetFileLine(expandConstant('{tmp}\files.txt'), 1, line2);
  url := line;
  appname := line2;    
  idpAddFile(url, ExpandConstant('{tmp}\'+appname));
  idpDownloadAfter(wpReady);
end;

此处第二个文件在第一个文件完成之前开始下载。那么如何制作一个接一个呢?

告诉 IDP 最初只下载列表。然后等待下载完成(参见 Running a program after it is downloaded in Code section in Inno Setup)并根据结果创建新的下载列表并重新开始下载。

var
  ListDownloaded: Boolean;

procedure InitializeWizard();
begin
  idpAddFile('http://www.example.com/files.txt', ExpandConstant('{tmp}\files.txt'));
  idpDownloadAfter(wpReady);
  ListDownloaded := False;
end;

function NextButtonClick(CurPageID: Integer): Boolean;
var
  Url, AppName: string;
begin
  Result := True;
  if CurPageID = IDPForm.Page.ID then
  begin
    if not ListDownloaded then
    begin
      TryGetFileLine(ExpandConstant('{tmp}\files.txt'), 0, Url);
      TryGetFileLine(ExpandConstant('{tmp}\files.txt'), 1, AppName);

      idpClearFiles;
      idpAddFile(Url, ExpandConstant('{tmp}\' + AppName));
      idpFormActivate(nil); { This restarts the download }
      Result := False;
      ListDownloaded := True;
    end;
  end;
end;