BeforeDownload callback function:

You can use the BeforeDownload parameter to specify a callback function when you make the DwinsHs_CurPageChanged procedure call. The callback function will be executed before the DwinsHs_CurPageChanged procedure starts to download the remote files which in the DwinsHs_DwonloadsList download queue.

Declaration:

type
  TBeforeDownload = function (): Boolean;

Return:

Returns true to start to download the remote file. Retunrs false to terminate the download operation, the DwinsHs_CurPageChanged procedure will return immediately, and the AfterDownload callback procedure will not be executed if it's defined.

Examples:

You can use the callback function to add new remote files to the DwinsHs_DwonloadsList download queue. Note, if you use the DwinsHs_AppendRemoteFile procedure to add a remote file, you need to install it by yourself using the Pascal script in the "[Code]" section, such as running it (if it's a executable file), extracting it to the application's folder (if it is an archive), or moving it to the application's folder (except the file was downloaded into the application's folder directly). You can do this in the AfterDownload callback procedure of the DwinsHs_CurPageChanged procedure, or the CurStepChanged event procedure:

function BeforeDownload(): Boolean;
begin
  ...
  DwinsHs_AppendRemoteFile(ExpandConstant('{tmp}\abc.dll'), 'http://www.domain.com/abc.dll',
    'My_Setup', rmGet, FILESIZE_QUERY_SERVER);
  DwinsHs_AppendRemoteFile(ExpandConstant('{app}\xyz.dll'), 'http://www.domain.com/xyz.dll',
    'My_Setup', rmGet, FILESIZE_QUERY_SERVER); // Download to application's folder directly
  ...
  Result := True;
end;
...
procedure AfterDownload(State: Integer);
begin
  ...
  if State = READ_OK then
    FileCopy(ExpandConstant('{tmp}\abc.dll'), ExpandConstant('{app}\abc.dll'), false);
  ...
end;
...
procedure CurPageChanged(CurPageID: Integer);
begin
  ...
  DwinsHs_CurPageChanged(CurPageID, @BeforeDownload, @AfterDownload);
  ...
end;

Also, you can use the callback function to add mirror sources for each remote file in the DwinsHs_DwonloadsList download queue, including files were added using the DwinsHs_AppendRemoteFile procedure in this callback function, and using the DwinsHs_Check function in the "[Files]" section:

function BeforeDownload(): Boolean;
begin
  ...
  DwinsHs_AppendMirrorFile(ExpandConstant('{tmp}\abc.dll'), 'http://www.domain2.com/abc.dll',
    'My_Setup', rmGet);
  DwinsHs_AppendMirrorFile(ExpandConstant('{tmp}\xyz.dll'), 'http://www.domain2.com/xyz.dll',
    'My_Setup', rmGet);
  ...
  Result := True;
end;
...
procedure CurPageChanged(CurPageID: Integer);
begin
  ...
  DwinsHs_CurPageChanged(CurPageID, @BeforeDownload, nil);
  ...
end;