开发者

Switch to the finish page in Inno Setup installation

I added a few custom pages to my setup. In one of this custom pages I do some checks. If this checks failed, I want switch to finish page. How can I do this?

I can not do this with ShouldSkipPage event function because:

function ShouldSkipPage(PageID: Integer): Boolean;
begin
  // this will NEVER happened - see documentation below
  if (PageID = wpInstalling) or (PageID = wpPreparing) 开发者_运维知识库or (PageID = wpWelcome) then
  begin
    // skip install - simply for example
    result := True;
    exit;
  end;

  resutl := false;
end;

From Inno Setup documentation:

The wizard calls this event function to determine whether or not a particular page (specified by PageID) should be shown at all. If you return True, the page will be skipped; if you return False, the page may be shown.

Note: This event function isn't called for the wpWelcome, wpPreparing, and wpInstalling pages, nor for pages that Setup has already determined should be skipped (for example, wpSelectComponents in an install containing no components).


I'm sorry, i did not understand why you cannot use ShouldSkipPage. The usual way of doing it is in ShouldSkipPage:

function ShouldSkipPage(curPageId : Integer) : Boolean;
begin
  {For a certain condition, skip to wpFinished}
  if (SomeCondition and (curPageId <> wpFinished)) then
    Result := True
  {Probably more checks}
  else
    Result := False
end;


If I understand you correctly, you are performing a check, and if it fails, you want to skip wpWelcome, wpPreparing, and wpInstalling (and perhaps more custom pages).

I assume that you also want to skip the actions performed when these pages are shown, specifically, you don't want to perform the installation step.

If that is the case, you should cancel the installation, not continue it without performing the actual installation steps. You can do it in InitializeSetup, for example:

Procedure InitializeSetup();
VAR
  Check: Integer;
BEGIN
  // perform you check here, set the variable according to it's result

  IF (Check <> 0) THEN
    // abort installation
    Return False;
  ELSE
    Return True;
END;

Edit
In response to your comment: The easiest solution would be to show a message box with the result of your check, instead of a complete wizard page. If that is not enough for your purposes I would suggest the following approach:

  1. Perform your check in InitializeSetup and store the result in a global variable.

  2. Create a new wizard page (lets call it CheckResult) to display the results of your check, it should be displayed directly after wpWelcome.

  3. In that page's OnNextButtonClick just call CancelButtonClick, that way the installation is always aborted when this page is displayed

  4. Now is the time to modify ShouldSkipPage ;-) If the global check variable indicates that everything is ok, skip your CheckResult page, so that the installation is not aborted automatically

This should work, but if you somehow can, follow the KISS principle and go with the message box approach.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜