开发者

Inno Setup: Install file from Internet

I am using Inno Setup to distribute my application开发者_高级运维. Is it possible to check in Inno Script for a particular condition and download and install some file from internet if required.


Inno Setup 6.1 and newer has a built-in support for downloads. No 3rd party solution are needed anymore.

Check the Examples\CodeDownloadFiles.iss in Inno Setup installation folder.

The important parts of the example are:

[Files]
; These files will be downloaded
Source: "{tmp}\innosetup-latest.exe"; DestDir: "{app}"; Flags: external
Source: "{tmp}\ISCrypt.dll"; DestDir: "{app}"; Flags: external
[Code]
var
  DownloadPage: TDownloadWizardPage;

function OnDownloadProgress(const Url, FileName: String; const Progress, ProgressMax: Int64): Boolean;
begin
  if Progress = ProgressMax then
    Log(Format('Successfully downloaded file to {tmp}: %s', [FileName]));
  Result := True;
end;

procedure InitializeWizard;
begin
  DownloadPage := CreateDownloadPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), @OnDownloadProgress);
end;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  if CurPageID = wpReady then begin
    DownloadPage.Clear;
    DownloadPage.Add('https://jrsoftware.org/download.php/is.exe', 'innosetup-latest.exe', '');
    DownloadPage.Add('https://jrsoftware.org/download.php/iscrypt.dll', 'ISCrypt.dll', '2f6294f9aa09f59a574b5dcd33be54e16b39377984f3d5658cda44950fa0f8fc');
    DownloadPage.Show;
    try
      try
        DownloadPage.Download;
        Result := True;
      except
        SuppressibleMsgBox(AddPeriod(GetExceptionMessage), mbCriticalError, MB_OK, IDOK);
        Result := False;
      end;
    finally
      DownloadPage.Hide;
    end;
  end else
    Result := True;
end;

Inno Setup: Install file from Internet


For alternatives, see Running a program after it is downloaded in Code section in Inno Setup


Inno Download Plugin by Mitrich Software.

  • It's an InnoSetup script and DLL, which allows you to download files as part of your installation.
  • It supports FTP, HTTP and HTTPS.
  • It's kind of a drop-in replacement for InnoTools Downloader. Only few changes required.
  • It brings a decent download display and HTTPS and Mirror(s) support.

Example:

#include <idp.iss>

[Files]
Source: "{tmp}\file.zip"; DestDir: "{app}"; Flags: external; ExternalSize: 1048576

[Code]
procedure InitializeWizard();
begin
  idpAddFileSize('http://127.0.0.1/file.zip', ExpandConstant('{tmp}\file.zip'), 1048576);

  idpDownloadAfter(wpReady);
end.


Yes, there is a library called InnoTools Downloader which has samples that do pretty much this. They can be conditioned on anything you want using normal Inno code.


Found on Inno 3rd Party is one very similar in scope and style to the Inno Download Plugin, DWinsHs.
Included with an easy and intuitive chm file which requires unblocking to view.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜