English 中文(简体)
摘自[Code]Inno Setup装置
原标题:Exit from Inno Setup installation from [Code]

能否从印无电装置创建的安装装置的<编码>[Code]部分的功能中退出安装?

我不想制定撤离守则,我想做的是按要求进行海关检查,如果以前没有安装这种要求,就离开安装。

问题回答

为防止安装机运行,在先决条件测试失败时,仅填写返回代码, 载于>>>>。 即便在洗劫机显示之前,该装置也将撤离。

function InitializeSetup(): Boolean;
begin
  Result := True;

  if not PrerequisitesTest then
  begin                     
    SuppressibleMsgBox( Prerequisites test failed , mbError, MB_OK, IDOK);
    Result := False;
  end;
end;

“entergraph


如果在安装开始之前需要测试前提条件(即<代码>InitializeSet太早,请打电话 编码>

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssInstall then
  begin
    if not PrerequisitesTest then
    begin                     
      SuppressibleMsgBox( Prerequisites test failed , mbError, MB_OK, IDOK);
      Abort;
    end;
  end;
end;

“在座的影像描述”/</a


在这种情形下,考虑使用>Prepare ToInstall 事件功能机制,而不是撤销设置。

function PrepareToInstall(var NeedsRestart: Boolean): String;
begin
  Result :=   ;

  if not PrerequisitesTest then
  begin                     
    Result :=  Prerequisites test failed ;
  end;
end;

“enterography


If you need to force terminate the installer any other time, use the ExitProcess WinAPI call:

procedure ExitProcess(uExitCode: Integer);
  external  ExitProcess@kernel32.dll stdcall ;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  if CurPageID = wpReady then
  begin
    if not PrerequisitesTest then
    begin                     
      SuppressibleMsgBox( Prerequisites test failed , mbError, MB_OK, IDOK);
      ExitProcess(1);
    end;
  end;
  Result := True;
end;

虽然这是相当不安全的撤离,但只是作为最后手段。 如果你装载了任何外部的DLL,你可能需要先卸载,以避免坠毁。 这也不清理临时名录。

“entergraph


如果你参加这些活动,可使用<>Abort():

InitializeSetup
InitializeWizard
CurStepChanged(ssInstall)
InitializeUninstall
CurUninstallStepChanged(usAppMutexCheck)
CurUninstallStepChanged(usUninstall)

我这样做的方式是:

procedure ExitProcess(exitCode:integer);
  external  ExitProcess@kernel32.dll stdcall ;

而使用这种方法的方式是:

[Code]
  if .... then begin
     ExitProcess(0);
  end;

这是我今天从Ino 5.6.1中 f出的文字,也是你在https://github.com/jrsoftware/issrc” rel=“noreferer”上找到的资料来源:https://github.com/jrsoftware/issrc[ref1]

A possibly useful catch-all solution to "Exit from [Code]"

TL;DR example:

[Code]
var _ImmediateInnoExit_was_invoked_flag: Boolean; // Inno/Pascal Script initializes all Boolean to False.

procedure ImmediateInnoExit();
  var MainFormRef: TForm;
begin
  _ImmediateInnoExit_was_invoked_flag := True;
  try
    MainFormRef := MainForm(); // calls GetMainForm() in Inno pascal code, which will raise an internal exception if the form is not yet initialized.
    Log( INFO: ImmediateInnoExit: Calling MainForm.Close()! );
    Log( NOTE: If the Event Fn CancelButtonClick is not coded to auto-Confirm, this will display the cancel dialog in the GUI case! );
    Log( NOTE: Code will stall inside the Close() function while the Cancel confirmation dialog is displayed. );
    MainFormRef.Close(); // this is only effective if the Wizard is visible, but we cann call it even when running siently (as long as the Wizard is initialized)
    Log( NOTE: MainForm.Close() invoked. (If confirmed, setup will exit.) );
  except
    Log( INFO: ImmediateInnoExit did not resolve MainForm -> assuming we were call in an InitializeSetup() context before the Main form has been created! );
  end;

  Log( INFO: ImmediateInnoExit: Calling Abort() -> EAbort! );
  Log( NOTE: Will exit the current scope. );
  Log( NOTE:   In GUI mode, it will just jump up to the Delphi event loop (and be ignored there). (But the WizardForm.Close() call should lead to exit!) );
  Log( NOTE:   In Silent Mode, it will be caught and exit the setup. );
  Abort(); // Raise EAbort
end;

// This is called when the user clicks the cancel button or the [x] Close button
// the close/cancel can be invoked from code via WizardForm.Close!
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin

  Log(Format( IN: CancelButtonClick(%d <- Cancel=[%d], Confirm=[%d]) , [CurPageID, Cancel, Confirm]));
  Confirm := not _ImmediateInnoExit_was_invoked_flag; // if Confirm==False we don t get the dialog prompt.
  Log(Format( IN: CancelButtonClick(%d -> [%d], [%d]) , [CurPageID, Cancel, Confirm]));
end;

如今,上述法典的内容是:

Anatomy of Inno Setup Exit/Cancel and Abort

Abort

The Inno docs for Abort state:

Description: Escapes from the current execution path without reporting an error.

Abort raises a special "silent exception" which operates like any other exception, but does not display an error message to the end user.

Remarks:
Abort does not cause Setup or Uninstall to exit unless it s called from one of these event functions (or another function invoked by them):

InitializeSetup InitializeWizard CurStepChanged(ssInstall) InitializeUninstall CurUninstallStepChanged(usAppMutexCheck) CurUninstallStepChanged(usUninstall)

Abort() behaviour explained

以这种方式来行使否决权的原因是,在内部,因诺提出“<>条码>的例外”,而这一例外是:rel=“noreferer” ,由Delphi UI loop专门处理,在所列出的职能中,Inno devs要么为bort/code>增添了特殊待遇。 CurStepChanged(ssInstall)<>[ref2], --

- 或通过国际不动产业证书不要求的功能,如<编码>InitializeSetup,该功能从和任何直接。 EAbortis, specified in the lessblock it.

在所有其他因诺事件职能(例如NextButtonClick等)中,EAbort的除外规定将送达主要方案/倡议,并被忽视。

让我们 to:

Abort() behaviour, when running /SILENT (or /VERSILENT)

在因诺默不作声时,它没有显示“国际倡议”的令人信服的形式。 然后是而不是,由国际不动产业联合会推动,但通过<代码>。 WizardForm.ClickThroughPages , 同一顶级try/vil各栏,例如InitializeSetup。 [参考3]

由于这一原因,如果因诺默不闻,Abort(>> 将在以北>上退出<>> > 大部分<代码>[Code]功能、 docs中给出的清单。 如果 set立不声,则

Cancel

为取消设置,用户可点击《设置令状》(<>>[Cancel]但顿或[X]、以及《设置令状令状》的近海纽尔。

在这种情况下,Inno将援引电话功能CancelButtonClick(CurPageID: Integer;var Cancel, Confirm: Boolean)。 (如果界定)和终止设置,可能的话,可以有逃跑的hat辩:

Called when the user clicks the Cancel button or clicks the window s Close button. The Cancel parameter specifies whether normal cancel processing should occur; it defaults to True. The Confirm parameter specifies whether an "Exit Setup?" message box should be displayed;

用户<<><>条码>[Code]可使用Cancel Button 色谱法,通过电话WizardForm.Close(),但只有安装显示“Wizard Form”,和 tt工作以沉默方式<>进行。

Cancel Details

WizardForm.Close<>>[ref4],或点击实际的纽扣,将最终称为TMainForm.FormClose Query(主编.pas),该编码将称为CancelButtonClick,[ref5],并依 Confirm Value, 要么打电话TerminateApp();直接或首先打电话给求助人ExitSetupMsgBox(,向用户显示电文箱。



Footnotes:

  • [ref1] : For non-delphi folks: If you search over the sources in you text editor, make sure to include at least .iss .pas and .dpr
  • [ref2] : ssInstall exception handling is located at issrcProjectsMain.pas: TMainForm.Install via SetStep(ssInstall, False); and the except block at the end of TMainForm.Install where TerminateApp is called.
  • [ref3] : See Setup.dpr calling MainForm.InitializeWizard from Main.paswhich calls WizardForm.ClickThroughPages iff not InstallMode = imNormal, i.e. in the silent case.
  • [ref4] : WizardForm.Close() internally calls MainForm.Close() (see: TWizardForm.FormClose)
  • [ref5] : There are actually two kinds of cancel button click callbacks defineable in Inno [Code]: The global CancelButtonClickprocedure, and each Wizard page also has a OnCancelButtonClick: TWizardPageCancelEvent that can be set.

在InnoSetup的帮助中,研究先天免疫和早孕。 正如科迪所说,这是可能的。 如果你再次出现问题,你会做些什么,你会再次出现问题。

Somewhere in your code section you perform a check. Right? As result of that check you want to exit the installation. To perform the exit put the line:

PostMessage (WizardForm.Handle, $0010, 0, 0);  { quit setup, $0010=WM_CLOSE }

希望这一帮助





相关问题
Changing AppID and AppName based on user input

I want to install the same application multiple times on the same system, for example for two user using two different web services (each one has their own). In in my setup script I want to change ...

InnoSetup: Getting AppName in [Code] section

I m creating an installer using InnoSetup, and writing some custom handlers in a [Code] section. In one of the handlers, I would like to be able to retrieve the value of the AppName (or, potentially, ...

Building Installation Disk for My Delphi 2010 Application

Can someone please give me a step by step on how to build an installation disk for my Delphi 2010 application? I have tried both InstallAware Express Edition which comes with Delphi 2010 but keeps on ...

Inno Setup custom welcome page

How can I customize the welcome page of an Inno Setup installer? I want to create an installer similar to Skype s installer with only 3 pages: Custom Welcome Page with some options Progress Page ...

Why would an ocx control not register properly?

I am writing an app that needs to use a third party ocx control. In my Inno Setup script I include the line: Source: C:aPathaControl.ocx; DestDir: {app}; Flags: restartreplace sharedfile regserver ...

Modifying the color scheme for an Inno Setup Installer

I ve been playing around with Inno Setup 5.3.6; trying to customize the installers colors. Mainly the banner that appears at the head of the installer. But as of yet i have no luck finding a way of ...

How do you distribute an HTML/Javascript web app?

I ve built a web page using HTML and Javascript that acts like a desktop app. I d like to distribute it to users in the methods they are most familiar with. For Windows users, I think this is an ...