【问题标题】:How to use NeedsRestart parameter of PrepareToTinstall function in Inno Setup?如何在 Inno Setup 中使用 PrepareToTinstall 函数的 NeedsRestart 参数?
【发布时间】:2020-11-04 19:16:48
【问题描述】:

AllPagesExample.iss 示例文件中有这部分:

function PrepareToInstall(var NeedsRestart: Boolean): String;
begin
  if SuppressibleMsgBox('Do you want to stop Setup at the Preparing To Install wizard page?', mbConfirmation, MB_YESNO, IDNO) = IDYES then
    Result := 'Stopped by user';
end;

如果PrepareToTinstall是一个事件函数,我自己不调用,怎么给它传递NeedsRestart参数呢?

【问题讨论】:

    标签: inno-setup pascalscript


    【解决方案1】:

    NeedsRestart 参数是passed by a referencevar 关键字)。所以它的值是从函数返回的,类似于函数本身的返回值(Result)。

    正如documentation 所说:

    返回一个非空字符串以指示安装程序在Preparing to Install 向导页面停止,将返回的字符串显示为错误消息。如果需要重新启动,请将 NeedsRestart 设置为 True(并返回非空字符串)。如果安装程序以这种方式停止,它将使用Setup Exit Codes 中所述的专用退出代码退出。

    所以,您要做的是为参数分配一个值,一旦事件函数退出,Inno Setup 将采取相应的行动。

    function PrepareToInstall(var NeedsRestart: Boolean): String;
    begin
      Result := '';
      if DoWeNeedRestartBeforeInstalling then
      begin
        Result := 'You need to restart your machine before installing';
        NeedsRestart := True;
      end;
    end;
    

    【讨论】:

      猜你喜欢
      • 2015-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多