inno-setup – 在Inno Setup的Code部分下载程序后运行程序

如何运行我通过Internet下载的应用程序,在代码部分中使用,并等待该应用程序完成运行.我有,使用InnoTools下载程序,下载这两个文件,我想,在第二个完成下载后运行该下载,或jdk-8u111-windows-x64.exe,然后继续安装.
[Code]

procedure InitializeWizard();
begin
  ITD_Init;

  ITD_AddFile('http://www-us.apache.org/dist/tomcat/tomcat-9/v9.0.0.M13/bin/apache-tomcat-9.0.0.M13-windows-x64.zip',expandconstant('{tmp}\apache-tomcat-9.0.0.M13-windows-x64.zip'));

  ITD_DownloadAfter(1);

  ITD_AddFile('http://files.downloadnow-1.com/s/software/15/62/36/39/jdk-8u111-windows-x64.exe?token=1479511171_b51e94edd4e002c94fd60a570a7dd270&fileName=jdk-8u111-windows-x64.exe',expandconstant('{tmp}\jdk-8u111-windows-x64.exe'));

  ITD_DownloadAfter(2);   
end;

解决方法

使用其他下载插件,而不是ITD(请参阅下面的原因).

例如,Inno Download Plugin.

当您包含idp.iss时,它定义了一个全局IDPForm结构.它的Page字段是TWizardPage,代表一个下载页面.下载完成后,使用NextButtonClick中的ID运行下载的文件(下载页面上的“下一步”按钮自动“按下”):

#include <idp.iss>

[Code]

procedure InitializeWizard;
begin
  idpAddFile(
    'https://www-us.apache.org/dist/tomcat/tomcat-9/v9.0.0.M13/bin/' +
      'apache-tomcat-9.0.0.M13-windows-x64.zip',ExpandConstant('{tmp}\apache-tomcat-9.0.0.M13-windows-x64.zip'));
  idpAddFile(
    'https://www.example.com/jdk-8u111-windows-x64.exe',ExpandConstant('{tmp}\jdk-8u111-windows-x64.exe'));
  idpDownloadAfter(wpSelectDir);
end;

function NextButtonClick(CurPageID: Integer): Boolean;
var
  ResultCode: Integer;
  FileName: string;
begin
  if CurPageID = IDPForm.Page.ID then
  begin
    FileName := ExpandConstant('{tmp}\jdk-8u111-windows-x64.exe');
    Result := Exec(FileName,'',SW_SHOW,ewWaitUntilTerminated,ResultCode);

    if not Result then
    begin
      MsgBox('Cannot execute sub-installer',mbError,MB_OK);
    end
      else
    begin
      Result := (ResultCode = 0);
      if not Result then
      begin
        MsgBox('Sub-installer failed',MB_OK);
      end
    end;
  end
    else
  begin
    Result := True;
  end;
end;

虽然您可以使用InnoTools Downloader实现相同功能,但您应该避免使用它:

>它已经过时,不再维护了;
>不支持Unicode Inno Setup(不要在新项目中使用Ansi Inno Setup);
>下载支持HTTPS;
>其下载页面does not scale on high DPI.

无论如何,为了完整性:ITD_DownloadAfter返回TWizardPage,表示下载页面.下载完成后,使用NextButtonClick中的ID运行下载的文件(下载页面上的“下一步”按钮自动“按下”):

var
  DownloadPage: TWizardPage;

procedure InitializeWizard(); 
begin 
  ITD_Init;
  ITD_AddFile(
    'http://www.example.com/jdk-8u111-windows-x64.exe',ExpandConstant('{tmp}\jdk-8u111-windows-x64.exe'));
  DownloadPage := ITD_DownloadAfter(wpSelectDir); 
end;

function NextButtonClick(CurPageID: Integer): Boolean;
var
  ResultCode: Integer;
begin
  if CurPageID = DownloadPage.ID then
  begin
    Result :=
      Exec(
        ExpandConstant('{tmp}\jdk-8u111-windows-x64.exe'),MB_OK);
      end
    end;
  end
    else
  begin
    Result := True;
  end;
end;

相关文章

 从网上看到《Delphi API HOOK完全说明》这篇文章,基本上都...
  从网上看到《Delphi API HOOK完全说明》这篇文章,基本上...
ffmpeg 是一套强大的开源的多媒体库 一般都是用 c/c+&#x...
32位CPU所含有的寄存器有:4个数据寄存器(EAX、EBX、ECX和ED...
1 mov dst, src dst是目的操作数,src是源操作数,指令实现的...