我在CurStepChanged(ssPostInstall)PascalScripting事件处理程序中的InnoSetup脚本中执行了很多自定义操作.由于这些操作需要一些时间才能完成,我想更新InnoSetup Wizard GUI状态文本并告诉用户幕后发生了什么.使用"StatusMsg"参数在[Run]部分中可能出现的类似情况.我知道我可以使用TOutputProgressWizardPage/CreateOutputProgressPage(),我在之前的项目中做过,但这对我来说有点太过分了......
是否更容易从PascalScripting代码更新InnoSetup Wizard GUI状态文本,其效果与StatusMsg参数相同?
我的应用程序需要安装.NET Framework,因此我在PrepareToIntall事件函数中运行.NET安装.在安装运行时,我想在向导上显示一些简单的消息.
我找到了如何在Inno安装脚本的[Code]部分设置状态消息?但那里的解决方案对我不起作用.
我试过了
WizardForm.StatusLabel.Caption := CustomMessage('InstallingDotNetMsg');
Run Code Online (Sandbox Code Playgroud)
并且
WizardForm.PreparingLabel.Caption := CustomMessage('InstallingDotNetMsg');
Run Code Online (Sandbox Code Playgroud)
编辑
我必须在PrepareToInstall函数中执行此操作,因为我需要在.net安装失败时停止设置.
代码现在看起来像这样:
function PrepareToInstall(var NeedsRestart: Boolean): String;
var
isDotNetInstalled : Boolean;
errorCode : Integer;
errorDesc : String;
begin
isDotNetInstalled := IsDotNetIntalledCheck();
if not isDotNetInstalled then
begin
//WizardForm.PreparingLabel.Caption := CustomMessage('InstallingDotNetMsg');
WizardForm.StatusLabel.Caption := CustomMessage('InstallingDotNetMsg');
ExtractTemporaryFile('dotNetFx40_Full_x86_x64.exe');
if not ShellExec('',ExpandConstant('{tmp}\dotNetFx40_Full_x86_x64.exe'),'/passive /norestart', '', SW_HIDE, ewWaitUntilTerminated, errorCode) then
begin
errorDesc := SysErrorMessage(errorCode);
MsgBox(errorDesc, mbError, MB_OK);
end;
isDotNetInstalled := WasDotNetInstallationSuccessful();
if not isDotNetInstalled then
begin
Result := CustomMessage('FailedToInstalldotNetMsg');
end; …Run Code Online (Sandbox Code Playgroud)