在Inno Setup中需要时如何防止显示启动画面?

时间:2020-04-06 13:53:55

标签: installation inno-setup splash-screen pascalscript issi

如何在需要时阻止显示初始屏幕? 我应该添加一些ISSI代码来做到这一点吗?

这是我的代码:

#define ISSI_Splash "C:\InnoSetupProject\Images\client.bmp"                 
#define ISSI_Splash_T 3
#define ISSI_Splash_X 500
#define ISSI_Splash_Y 220 

[Code]
function ISSI_InitializeSetup : Boolean;
begin       
  Result := True;
  if not RegValueExists(HKLM, 'SOFTWARE\MyApp\Client', 'LocaleID') then
    if MsgBox('Client does not exist', mbCriticalError, MB_OK) = IDOK then
      begin
        Result := False;
        { How can I prevent showing the splash screen here? }
        Exit;
      end  
end;

#define ISSI_InitializeSetup
#define ISSI_IncludePath "C:\ISSI" 
#include ISSI_IncludePath+"\_issi.isi"

1 个答案:

答案 0 :(得分:2)

使用Inno Setup 6 event attributes代替传统的ISSI_InitializeSetup功能:

[Code]
<event('InitializeSetup')>
function MyInitializeSetup: Boolean;
begin       
  Result := True;
  if not RegValueExists(HKLM, 'SOFTWARE\MyApp\Client', 'LocaleID') then
    if MsgBox('Client does not exist', mbCriticalError, MB_OK) = IDOK then
      begin
        Result := False; 
      end;
end;

并删除此内容:

#define ISSI_InitializeSetup

将在ISSI MyInitializeSetup之前调用InitializeSetup。如果返回False,则将永远不会调用ISSI,因此不会显示初始屏幕。

查看Event Attributes的文档:

  • 将按照定义的定义顺序调用实现,但将主要实现(=不具有事件属性的实现)称为最后一个

  • 如果事件函数具有返回值,则执行惰性计算: InitializeSetupBackButtonClickNextButtonClickInitializeUninstall

    • 所有实现都必须返回True,事件函数才能被视为返回True,返回False的实现将停止对其他实现的调用。