Search code examples
inno-setuppascalscriptinno-download-plugin

Inno Setup Download file from location based on user input


I wondering how send input from UserPage to idpAddFile to download it by Inno Download Plugin. After download I would like to use that zip and install app.

For now I have this:

var
  UserPage: TInputQueryWizardPage;

procedure InitializeWizard;
begin
  {Page for input Version}
  UserPage := CreateInputQueryPage(wpWelcome,
    'Number of Version', 'example : 1.8.20',
    'Program will download your input');
  UserPage.Add('Version:', False);
  UserPage.Values[0] := GetPreviousData('Version', '1.8.20');

  {Download file from input}
  idpAddFile(
    '127.0.0.1/repository/GU/my-apps/app.zip/{input}/ia-client.zip-{input}.zip',
    ExpandConstant('{tmp}\{input}.zip}'));
  idpDownloadAfter(wpReady);
end;

thanks for suggestion and help


Solution

  • Call the idpAddFile only just before the download starts, from NextButtonClick(wpReady), when you already know the version and the user has no chance to change it anymore:

    function NextButtonClick(CurPageID: Integer): Boolean;
    var
      Version: string;
      FileURL: string;
    begin
      if CurPageID = wpReady then
      begin
        Version := UserPage.Values[0];
        FileURL := Format('http://www.example.com/path/%s/app-%0:s.zip', [Version]); 
        idpAddFile(FileURL, ExpandConstant(Format('{tmp}\app-%s.zip', [Version])));
      end;
      Result := True;
    end;