CodeDownloadFiles.iss 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. ; -- CodeDownloadFiles.iss --
  2. ;
  3. ; SEE DOWNLOADFILES.ISS FIRST!
  4. ;
  5. ; This script shows how the CreateDownloadPage support function can be used to
  6. ; download and verify files while showing the download progress to the user.
  7. [Setup]
  8. AppName=My Program
  9. AppVersion=1.5
  10. WizardStyle=modern
  11. DefaultDirName={autopf}\My Program
  12. DefaultGroupName=My Program
  13. UninstallDisplayIcon={app}\MyProg.exe
  14. OutputDir=userdocs:Inno Setup Examples Output
  15. ;Use "ArchiveExtraction=enhanced" if your archive has a password
  16. ;Use "ArchiveExtraction=full" if your archive is not a .7z file but for example a .zip file
  17. ArchiveExtraction=enhanced/nopassword
  18. [ISSigKeys]
  19. Name: mykey; RuntimeID: def02; \
  20. KeyID: "def020edee3c4835fd54d85eff8b66d4d899b22a777353ca4a114b652e5e7a28"; \
  21. PublicX: "515dc7d6c16d4a46272ceb3d158c5630a96466ab4d948e72c2029d737c823097"; \
  22. PublicY: "f3c21f6b5156c52a35f6f28016ee3e31a3ded60c325b81fb7b1f88c221081a61"
  23. [Files]
  24. ; Place any regular files here
  25. Source: "MyProg.exe"; DestDir: "{app}"
  26. Source: "MyProg.chm"; DestDir: "{app}"
  27. Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme
  28. ; These files will be downloaded. If you include flag issigverify here the file will be verified
  29. ; a second time while copying. Verification while copying is efficient, except for archives.
  30. Source: "{tmp}\innosetup-latest.exe"; DestDir: "{app}"; Flags: external ignoreversion issigverify
  31. Source: "{tmp}\MyProg-ExtraReadmes.7z"; DestDir: "{app}"; Flags: external extractarchive recursesubdirs ignoreversion
  32. Source: "{tmp}\ISCrypt.dll"; DestDir: "{app}"; Flags: external ignoreversion
  33. [Icons]
  34. Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"
  35. [Code]
  36. var
  37. DownloadPage: TDownloadWizardPage;
  38. AllowedKeysRuntimeIDs: TStringList;
  39. procedure InitializeWizard;
  40. begin
  41. DownloadPage := CreateDownloadPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), nil);
  42. DownloadPage.ShowBaseNameInsteadOfUrl := True;
  43. // To allow all keys you can also just pass nil instead of this list to AddWithISSigVerify
  44. AllowedKeysRuntimeIDs := TStringList.Create;
  45. AllowedKeysRuntimeIDs.Add('def02');
  46. end;
  47. procedure DeinitializeSetup;
  48. begin
  49. if AllowedKeysRuntimeIDs <> nil then
  50. AllowedKeysRuntimeIDs.Free;
  51. end;
  52. function NextButtonClick(CurPageID: Integer): Boolean;
  53. var
  54. Error: String;
  55. begin
  56. if CurPageID = wpReady then begin
  57. DownloadPage.Clear;
  58. // Use AddEx or AddExWithISSigVerify to specify a username and password
  59. DownloadPage.AddWithISSigVerify(
  60. 'https://jrsoftware.org/download.php/is.exe?dontcount=1', '',
  61. 'innosetup-latest.exe', AllowedKeysRuntimeIDs);
  62. DownloadPage.AddWithISSigVerify(
  63. 'https://jrsoftware.org/download.php/myprog-extrareadmes.7z', '',
  64. 'MyProg-ExtraReadmes.7z', AllowedKeysRuntimeIDs);
  65. DownloadPage.Add(
  66. 'https://jrsoftware.org/download.php/iscrypt.dll?dontcount=1',
  67. 'ISCrypt.dll', '2f6294f9aa09f59a574b5dcd33be54e16b39377984f3d5658cda44950fa0f8fc');
  68. DownloadPage.Show;
  69. try
  70. try
  71. DownloadPage.Download; // This downloads the files to {tmp}
  72. Result := True;
  73. except
  74. if DownloadPage.AbortedByUser then
  75. Log('Aborted by user.')
  76. else begin
  77. Error := Format('%s: %s', [DownloadPage.LastBaseNameOrUrl, GetExceptionMessage]);
  78. SuppressibleMsgBox(AddPeriod(Error), mbCriticalError, MB_OK, IDOK);
  79. end;
  80. Result := False;
  81. end;
  82. finally
  83. DownloadPage.Hide;
  84. end;
  85. end else
  86. Result := True;
  87. end;