使用 inno-setup 在安装过程中显示文本

Show text during installation process with inno-setup

我正在寻找一种可能性,以便向用户显示有关如何在安装可再发行组件期间继续操作的说明。

背景: 我有一些需要第三方安装的组件,这些组件非常复杂。如果用户选择这些组件之一,则会显示一个带有说明的消息框。在此框之后,resistributables 通过 exec/shellExec 和 'ewWaitUntilTerminated' 执行。不幸的是,用户在安装过程中看不到该框。

我尝试只在记事本中打开笔记并使用 'ewNoWait',但每次安装 redistributalbe 后它都不会自动关闭。用户可以选择这些组件中的多个,并且此帮助应该仅在特定安装期间可见。无法使用 taskkill 杀死记事本,它可能会杀死用户打开的记事本。

有什么优雅的方法可以实现这种行为吗?

使用函数 http://www.jrsoftware.org/ishelp/index.php?topic=isxfunc_createoutputprogresspage

创建 TOutputProgressWizardPage
function CreateOutputProgressPage(const ACaption, ADescription: String): TOutputProgressWizardPage;

[Code]
var
  ProgressPage: TOutputProgressWizardPage;

procedure InitializeWizard;
begin
  ProgressPage := CreateOutputProgressPage('Finalization of installation','');
end;

procedure CurPageChanged(CurPageID: Integer);
var
  I: Integer;
begin
  // Page is shown after installation when Finish page is shown
  if CurPageID = wpFinish then begin
    ProgressPage.SetText('Installing some 3rd party stuff...', '');
    ProgressPage.SetProgress(0, 0);
    ProgressPage.Show;
    try
      // Use exec/shellExec here to execute 3rd party app

      // Also you can adjust progress barr position here:
      for I := 0 to 10 do begin
        ProgressPage.SetProgress(I, 10);
        Sleep(100);
      end;
    finally
      ProgressPage.Hide;
    end;
  end else
    Result := True;
end;

我终于找到了解决问题的方法。根据 Slappy 的回答,我使用了 std MsgPage 并根据需要调整了它的大小。感谢 TLama 在不同主题中对调整大小代码的回答!

[Code]
var 
  RedistPage:   TOutputMsgWizardPage;

  DefaultTop, 
  DefaultLeft, 
  DefaultHeight,
  DefaultBackTop, 
  DefaultNextTop, 
  DefaultCancelTop,
  DefaultBevelTop, 
  DefaultBeveledLabelTop,
  DefaultInnerHeight,
  DefaultOuterHeight: Integer;

procedure InitializeWizard();
var 
  ReadMe: AnsiString;

begin

DefaultTop                  := WizardForm.Top;
DefaultLeft                 := WizardForm.Left;
DefaultHeight               := WizardForm.Height;
DefaultBackTop              := WizardForm.BackButton.Top;
DefaultNextTop              := WizardForm.NextButton.Top;
DefaultCancelTop            := WizardForm.CancelButton.Top;
DefaultBevelTop             := WizardForm.Bevel.Top;
DefaultBeveledLabelTop      := WizardForm.BeveledLabel.Top;
DefaultOuterHeight          := WizardForm.OuterNotebook.Height;
DefaultInnerHeight          := WizardForm.InnerNotebook.Height;

// save the contents of Readme.txt (non Unicode) in a string and build custom page
try
    ExtractTemporaryFiles('{tmp}\readme.txt');
    if LoadStringFromFile(ExpandConstant('{tmp}\readme.txt'), ReadMe) then
        RedistPage := CreateOutputMsgPage(wpReady,
            'Information', 'Please read the following important information about the installation before continuing.',ReadMe);
except
    ShowExceptionMessage;
end;

function ShouldSkipPage(PageID: Integer): Boolean;
begin
  Result := False;   // initialize result to not skip any page (not necessary, but safer)
  if PageID = RedistPage.ID then // if the page that is asked to be skipped is your custom page, then...
    Result := not IsTaskSelected('dexela_API');  // if the task is not selected, skip the page
end;

procedure ChangePageSize(HeightOffset: Integer);
begin
    WizardForm.Top := DefaultTop - (HeightOffset - DefaultHeight) div 2;
    WizardForm.Height := WizardForm.Height + (HeightOffset - DefaultHeight);
    WizardForm.InnerPage.Height := WizardForm.InnerPage.Height + (HeightOffset - DefaultHeight);
    WizardForm.InnerNotebook.Height :=  WizardForm.InnerNotebook.Height + (HeightOffset - DefaultHeight);
    WizardForm.OuterNotebook.Height := WizardForm.OuterNotebook.Height + (HeightOffset - DefaultHeight);
    WizardForm.CancelButton.Top := DefaultCancelTop + (HeightOffset - DefaultHeight);
    WizardForm.NextButton.Top := DefaultNextTop + (HeightOffset - DefaultHeight);
    WizardForm.BackButton.Top := DefaultBackTop + (HeightOffset - DefaultHeight);
    WizardForm.Bevel.Top := DefaultBevelTop + (HeightOffset - DefaultHeight);
end;

procedure CurPageChanged(CurPageID: Integer);
var 
    ComponentsPageTextHeight: Integer;
begin
    if (CurPageID = RedistPage.ID) and (IsTaskSelected('dexela_API'))then begin
        ChangePageSize(650);
        //Sleep(2000); // time for the user to recognize the text, before it is hidden by installer
        // Extract all Dexela files and launch them.
        try
            ExtractTemporaryFiles('{tmp}\Setup.msi');
        except
            ShowExceptionMessage;
        end;
        ShellExec('',ExpandConstant('{tmp}\Setup.msi'), '', '',SW_SHOW, ewWaitUntilTerminated, ResultCode);
    end;
end;