我正在使用Inno Setup来分发我的应用程序。 是否可以在Inno Script中查看特定条件,并在需要时从Internet下载并安装一些文件。
答案 0 :(得分:10)
是的,有一个名为InnoTools Downloader的库,它的样本几乎可以做到这一点。使用普通的Inno代码,它们可以满足您的任何需求。
答案 1 :(得分:10)
答案 2 :(得分:5)
Inno Setup 6.1 具有内置的下载支持。不再需要第三方解决方案。
检查 Inno Setup 安装文件夹中的 Examples\CodeDownloadFiles.iss
。
该示例的重要部分是:
[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;
有关替代方案,请参阅 Running a program after it is downloaded in Code section in Inno Setup
答案 3 :(得分:0)
在Inno 3rd Party上找到与Inno下载插件DWinsHs非常相似的范围和风格。
包含一个简单直观的chm文件,需要unblocking才能查看。