我的应用程序需要安装 .NET Framework,因此我运行 .NET 安装准备安装事件函数。当安装运行时,我想在向导上显示一些简单的消息。
I found 如何在 Inno 安装脚本的 [Code] 部分设置状态消息? https://stackoverflow.com/q/8612117/1456174但那里的解决方案对我不起作用。
I tried
WizardForm.StatusLabel.Caption := CustomMessage('InstallingDotNetMsg');
and also
WizardForm.PreparingLabel.Caption := CustomMessage('InstallingDotNetMsg');
EDIT
我必须这样做准备安装功能,因为我需要在.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;
end;
end;
有什么想法如何实现这一目标吗?
The StatusLabel
是由InstallingPage
当您打开时的向导页面PreparingPage
页面中的PrepareToInstall
事件方法。所以这是一个错误的标签。您尝试将文本设置为PreparingLabel
是正确的,但失败了,因为默认情况下该标签是隐藏的(当您将非空字符串作为事件方法的结果返回时,它会显示)。
但你可以展示它一段时间(你正在使用ewWaitUntilTerminated
标志,因此您的安装是同步的,因此不会造成任何损害):
[Code]
function PrepareToInstall(var NeedsRestart: Boolean): String;
var
WasVisible: Boolean;
begin
// store the original visibility state
WasVisible := WizardForm.PreparingLabel.Visible;
try
// show the PreparingLabel
WizardForm.PreparingLabel.Visible := True;
// set a label caption
WizardForm.PreparingLabel.Caption := CustomMessage('InstallingDotNetMsg');
// do your installation here
finally
// restore the original visibility state
WizardForm.PreparingLabel.Visible := WasVisible;
end;
end;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)