首页 > 解决方案 > 在 Inno Setup 中需要时如何防止显示启动画面?

问题描述

如何在需要时防止显示启动画面?我应该添加一些 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"

标签: installationinno-setupsplash-screenpascalscriptissi

解决方案


代替旧ISSI_InitializeSetup功能,使用 Inno Setup 6事件属性

[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

MyInitializeSetup在 ISSI 之前调用InitializeSetup。如果它返回False,则永远不会调用 ISSI,因此不会显示启动画面。

检查事件属性的文档:

  • 实现将按其定义的顺序被调用,除了任何主要实现(=没有事件属性的实现)将被最后调用

  • 如果事件函数有返回值,则执行惰性求值: InitializeSetup, BackButtonClick, NextButtonClick, InitializeUninstall:

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

推荐阅读