CodeDownloadFiles.iss 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ; -- CodeDownloadFiles.iss --
  2. ;
  3. ; This script shows how the CreateDownloadPage support function can be used to
  4. ; download temporary files while showing the download progress to the user.
  5. [Setup]
  6. AppName=My Program
  7. AppVersion=1.5
  8. WizardStyle=modern
  9. DefaultDirName={autopf}\My Program
  10. DefaultGroupName=My Program
  11. UninstallDisplayIcon={app}\MyProg.exe
  12. OutputDir=userdocs:Inno Setup Examples Output
  13. [Files]
  14. ; Place any regular files here
  15. Source: "MyProg.exe"; DestDir: "{app}";
  16. Source: "MyProg.chm"; DestDir: "{app}";
  17. Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme;
  18. ; These files will be downloaded
  19. Source: "{tmp}\innosetup-latest.exe"; DestDir: "{app}"; Flags: external
  20. Source: "{tmp}\ISCrypt.dll"; DestDir: "{app}"; Flags: external
  21. [Icons]
  22. Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"
  23. [Code]
  24. var
  25. DownloadPage: TDownloadWizardPage;
  26. function OnDownloadProgress(const Url, FileName: String; const Progress, ProgressMax: Int64): Boolean;
  27. begin
  28. if Progress = ProgressMax then
  29. Log(Format('Successfully downloaded file to {tmp}: %s', [FileName]));
  30. Result := True;
  31. end;
  32. procedure InitializeWizard;
  33. begin
  34. DownloadPage := CreateDownloadPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), @OnDownloadProgress);
  35. end;
  36. function NextButtonClick(CurPageID: Integer): Boolean;
  37. begin
  38. if CurPageID = wpReady then begin
  39. DownloadPage.Clear;
  40. DownloadPage.Add('https://jrsoftware.org/download.php/is.exe', 'innosetup-latest.exe', '');
  41. DownloadPage.Add('https://jrsoftware.org/download.php/iscrypt.dll', 'ISCrypt.dll', '2f6294f9aa09f59a574b5dcd33be54e16b39377984f3d5658cda44950fa0f8fc');
  42. DownloadPage.Show;
  43. try
  44. try
  45. DownloadPage.Download; // This downloads the files to {tmp}
  46. Result := True;
  47. except
  48. if DownloadPage.AbortedByUser then
  49. Log('Aborted by user.')
  50. else
  51. SuppressibleMsgBox(AddPeriod(GetExceptionMessage), mbCriticalError, MB_OK, IDOK);
  52. Result := False;
  53. end;
  54. finally
  55. DownloadPage.Hide;
  56. end;
  57. end else
  58. Result := True;
  59. end;