2020-07-09 11:09:30 +02:00
|
|
|
; -- CodeDownloadFiles.iss --
|
|
|
|
;
|
2020-07-23 20:08:26 +02:00
|
|
|
; This script shows how the CreateDownloadPage support function can be used to
|
|
|
|
; download temporary files while showing the download progress to the user.
|
2025-04-28 17:51:22 +02:00
|
|
|
;
|
|
|
|
; To verify the downloaded files, this script shows two methods:
|
|
|
|
; -For innosetup-latest.exe: using the Inno Setup Signature Tool, the [ISSigKeys]
|
|
|
|
; section, and the issigverify flag
|
|
|
|
; -For iscrypt.dll: using a simple SHA256 check
|
|
|
|
; Using the Inno Setup Signature Tool has the benefit that the script does not
|
|
|
|
; need to be changed when the downloaded file changes, so any installers built
|
|
|
|
; will also keep working
|
2020-07-09 11:09:30 +02:00
|
|
|
|
|
|
|
[Setup]
|
|
|
|
AppName=My Program
|
|
|
|
AppVersion=1.5
|
|
|
|
WizardStyle=modern
|
|
|
|
DefaultDirName={autopf}\My Program
|
|
|
|
DefaultGroupName=My Program
|
|
|
|
UninstallDisplayIcon={app}\MyProg.exe
|
|
|
|
OutputDir=userdocs:Inno Setup Examples Output
|
|
|
|
|
2025-04-28 17:51:22 +02:00
|
|
|
[ISSigKeys]
|
2025-04-30 17:42:01 +02:00
|
|
|
Name: "mykey"; \
|
|
|
|
KeyID: "def020edee3c4835fd54d85eff8b66d4d899b22a777353ca4a114b652e5e7a28"; \
|
|
|
|
PublicX: "515dc7d6c16d4a46272ceb3d158c5630a96466ab4d948e72c2029d737c823097"; \
|
|
|
|
PublicY: "f3c21f6b5156c52a35f6f28016ee3e31a3ded60c325b81fb7b1f88c221081a61"
|
2025-04-28 17:51:22 +02:00
|
|
|
|
2020-07-09 11:09:30 +02:00
|
|
|
[Files]
|
|
|
|
; Place any regular files here
|
|
|
|
Source: "MyProg.exe"; DestDir: "{app}";
|
|
|
|
Source: "MyProg.chm"; DestDir: "{app}";
|
|
|
|
Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme;
|
|
|
|
; These files will be downloaded
|
2025-04-28 17:51:22 +02:00
|
|
|
Source: "{tmp}\innosetup-latest.exe"; DestDir: "{app}"; Flags: external ignoreversion issigverify
|
|
|
|
Source: "{tmp}\ISCrypt.dll"; DestDir: "{app}"; Flags: external ignoreversion
|
2020-07-09 11:09:30 +02:00
|
|
|
|
|
|
|
[Icons]
|
|
|
|
Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"
|
|
|
|
|
|
|
|
[Code]
|
|
|
|
var
|
2020-07-23 20:08:26 +02:00
|
|
|
DownloadPage: TDownloadWizardPage;
|
2020-07-09 11:09:30 +02:00
|
|
|
|
2020-07-23 20:08:26 +02:00
|
|
|
function OnDownloadProgress(const Url, FileName: String; const Progress, ProgressMax: Int64): Boolean;
|
2020-07-09 11:09:30 +02:00
|
|
|
begin
|
2020-07-23 20:08:26 +02:00
|
|
|
if Progress = ProgressMax then
|
|
|
|
Log(Format('Successfully downloaded file to {tmp}: %s', [FileName]));
|
|
|
|
Result := True;
|
2020-07-09 11:09:30 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure InitializeWizard;
|
|
|
|
begin
|
2020-07-23 20:08:26 +02:00
|
|
|
DownloadPage := CreateDownloadPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), @OnDownloadProgress);
|
2024-05-22 11:09:56 +02:00
|
|
|
DownloadPage.ShowBaseNameInsteadOfUrl := True;
|
2020-07-23 20:08:26 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function NextButtonClick(CurPageID: Integer): Boolean;
|
|
|
|
begin
|
|
|
|
if CurPageID = wpReady then begin
|
|
|
|
DownloadPage.Clear;
|
2023-02-13 12:57:10 +01:00
|
|
|
// Use AddEx to specify a username and password
|
2024-05-22 10:34:19 +02:00
|
|
|
DownloadPage.Add('https://jrsoftware.org/download.php/is.exe?dontcount=1', 'innosetup-latest.exe', '');
|
2025-04-28 17:51:22 +02:00
|
|
|
DownloadPage.Add('https://jrsoftware.org/download.php/is.exe.issig?dontcount=1', 'innosetup-latest.exe.issig', '');
|
2024-05-22 10:34:19 +02:00
|
|
|
DownloadPage.Add('https://jrsoftware.org/download.php/iscrypt.dll?dontcount=1', 'ISCrypt.dll', '2f6294f9aa09f59a574b5dcd33be54e16b39377984f3d5658cda44950fa0f8fc');
|
2020-07-23 20:08:26 +02:00
|
|
|
DownloadPage.Show;
|
|
|
|
try
|
|
|
|
try
|
2021-03-11 13:43:03 +01:00
|
|
|
DownloadPage.Download; // This downloads the files to {tmp}
|
2020-07-23 20:08:26 +02:00
|
|
|
Result := True;
|
|
|
|
except
|
2020-12-10 13:56:46 +01:00
|
|
|
if DownloadPage.AbortedByUser then
|
|
|
|
Log('Aborted by user.')
|
|
|
|
else
|
|
|
|
SuppressibleMsgBox(AddPeriod(GetExceptionMessage), mbCriticalError, MB_OK, IDOK);
|
2020-07-23 20:08:26 +02:00
|
|
|
Result := False;
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
DownloadPage.Hide;
|
|
|
|
end;
|
|
|
|
end else
|
2020-07-20 19:36:49 +02:00
|
|
|
Result := True;
|
2020-07-23 20:08:26 +02:00
|
|
|
end;
|