您可以通过调用来执行它Exec http://jrsoftware.org/ishelp/topic_isxfunc_exec.htm函数从CurStepChanged http://jrsoftware.org/ishelp/topic_scriptevents.htm#CurStepChanged事件方法,当步骤将是ssInstall
。下面的脚本显示了如何将 MySQL 安装程序包含到您的安装中以及如何在安装开始之前提取并执行它:
#define MySQLInstaller "mysql-essential-6.0.11-alpha-winx64.msi"
[Files]
Source: "{#MySQLInstaller}"; Flags: dontcopy
[Code]
procedure CurStepChanged(CurStep: TSetupStep);
var
Params: string;
ResultCode: Integer;
begin
if (CurStep = ssInstall) then
begin
ExtractTemporaryFile('{#MySQLInstaller}');
Params := '/i ' + AddQuotes(ExpandConstant('{tmp}\{#MySQLInstaller}')) + ' /qn';
if not Exec('msiexec', Params, '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
MsgBox('Installation of MySQL failed. Exit code: ' + IntToStr(ResultCode),
mbInformation, MB_OK);
end;
end;
利用未使用的进度条:
由于 MySQL 安装完成需要一些时间,并且您决定隐藏安装程序的用户界面(无论如何这也可能非常不安全),因此您可以扩展脚本以使用其显示的进度条安装期间的起始位置并且当时未使用。以下代码将(至少在 Windows XP 系统上)Inno Setup 的安装进度条切换为marquee style http://msdn.microsoft.com/en-us/library/windows/desktop/bb760816%28v=vs.85%29.aspx#Marquee_Style并在状态标签中显示说明。 MySQL 安装完成后,进度条切换回正常模式,并开始实际的 Inno Setup 安装:
#define MySQLInstaller "mysql-essential-6.0.11-alpha-winx64.msi"
[Files]
Source: "{#MySQLInstaller}"; Flags: dontcopy
[Code]
procedure CurStepChanged(CurStep: TSetupStep);
var
Params: string;
ResultCode: Integer;
begin
if (CurStep = ssInstall) then
begin
WizardForm.ProgressGauge.Style := npbstMarquee;
WizardForm.StatusLabel.Caption := 'Installing MySQL. This may take a few minutes...';
ExtractTemporaryFile('{#MySQLInstaller}');
Params := '/i ' + AddQuotes(ExpandConstant('{tmp}\{#MySQLInstaller}')) + ' /qn';
if not Exec('msiexec', Params, '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
MsgBox('Installation of MySQL failed. Exit code: ' + IntToStr(ResultCode),
mbInformation, MB_OK);
WizardForm.ProgressGauge.Style := npbstNormal;
WizardForm.StatusLabel.Caption := '';
end;
end;