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

How can I prevent showing the splash screen when I need it in 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"

使用 Inno Setup 6 而不是传统的 ISSI_InitializeSetup 函数 event attributes:

[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 之前调用。如果它 returns False,将永远不会调用 ISSI,因此不会显示启动画面。

查看 Event Attributes 的文档:

  • The implementations will be called in order of their definition except that any main implementation (=the implementation without an event attribute) will be called last.

  • If the event function has a return value then lazy evaluation is performed: InitializeSetup, BackButtonClick, NextButtonClick, InitializeUninstall:

    • All implementations must return True for the event function to be treated as returning True and an implementation returning False stops the calls to the other implementations.