如何运行我通过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;
答案 0 :(得分:1)
使用其他下载插件,而不是ITD(请参阅下面的原因)。
当您加入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', mbError, MB_OK);
end
end;
end
else
begin
Result := True;
end;
end;
虽然您可以使用InnoTools Downloader实现相同功能,但您应该避免使用它:
无论如何,为了完整性:ITD_DownloadAfter
返回TWizardPage
,表示下载页面。下载完成后,使用NextButtonClick
中的ID运行下载的文件(下载页面上的&#34;下一步&#34;按钮是&#34;按下&#34;自动):
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'),
'', '', 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', mbError, MB_OK);
end
end;
end
else
begin
Result := True;
end;
end;