CodeDownloadFiles.iss 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 dynamic
  11. DefaultDirName={autopf}\My Program
  12. DefaultGroupName=My Program
  13. UninstallDisplayIcon={app}\MyProg.exe
  14. OutputDir=userdocs:Inno Setup Examples Output
  15. ArchiveExtraction=enhanced/nopassword
  16. ; Use "ArchiveExtraction=enhanced" if your archive has a password
  17. ; Use "ArchiveExtraction=full" if your archive is not a .7z file but for example a .zip file
  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
  29. Source: "{tmp}\innosetup-latest.exe"; DestDir: "{app}"; Flags: external ignoreversion issigverify
  30. Source: "{tmp}\MyProg-ExtraReadmes.7z"; DestDir: "{app}"; Flags: external extractarchive recursesubdirs ignoreversion
  31. Source: "{tmp}\ISCrypt.dll"; DestDir: "{app}"; Flags: external ignoreversion
  32. [Icons]
  33. Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"
  34. [Code]
  35. var
  36. DownloadPage: TDownloadWizardPage;
  37. AllowedKeysRuntimeIDs: TStringList;
  38. procedure InitializeWizard;
  39. begin
  40. DownloadPage := CreateDownloadPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), nil);
  41. DownloadPage.ShowBaseNameInsteadOfUrl := True;
  42. // To allow all keys you can also just pass nil instead of this list to AddWithISSigVerify
  43. AllowedKeysRuntimeIDs := TStringList.Create;
  44. AllowedKeysRuntimeIDs.Add('def02');
  45. end;
  46. procedure DeinitializeSetup;
  47. begin
  48. if AllowedKeysRuntimeIDs <> nil then
  49. AllowedKeysRuntimeIDs.Free;
  50. end;
  51. function NextButtonClick(CurPageID: Integer): Boolean;
  52. var
  53. Error: String;
  54. begin
  55. if CurPageID = wpReady then begin
  56. DownloadPage.Clear;
  57. // Use AddEx or AddExWithISSigVerify to specify a username and password
  58. DownloadPage.AddWithISSigVerify(
  59. 'https://jrsoftware.org/download.php/is.exe?dontcount=1', '',
  60. 'innosetup-latest.exe', AllowedKeysRuntimeIDs);
  61. DownloadPage.AddWithISSigVerify(
  62. 'https://jrsoftware.org/download.php/myprog-extrareadmes.7z', '',
  63. 'MyProg-ExtraReadmes.7z', AllowedKeysRuntimeIDs);
  64. DownloadPage.Add(
  65. 'https://jrsoftware.org/download.php/iscrypt.dll?dontcount=1',
  66. 'ISCrypt.dll', '2f6294f9aa09f59a574b5dcd33be54e16b39377984f3d5658cda44950fa0f8fc');
  67. DownloadPage.Show;
  68. try
  69. try
  70. DownloadPage.Download; // This downloads the files to {tmp}
  71. Result := True;
  72. except
  73. if DownloadPage.AbortedByUser then
  74. Log('Aborted by user.')
  75. else begin
  76. Error := Format('%s: %s', [DownloadPage.LastBaseNameOrUrl, GetExceptionMessage]);
  77. SuppressibleMsgBox(AddPeriod(Error), mbCriticalError, MB_OK, IDOK);
  78. end;
  79. Result := False;
  80. end;
  81. finally
  82. DownloadPage.Hide;
  83. end;
  84. end else
  85. Result := True;
  86. end;