Inno setup Inno-自定义页面优先于任何其他内容

Inno setup Inno-自定义页面优先于任何其他内容,inno-setup,Inno Setup,我们正在将应用程序切换到.Net4,但我们仍有Windows XP SP2上的客户。因此,我需要在设置中进行附加检查 在安装开始时弹出一条消息以丢弃XP SP2用户非常简单: function InitializeSetup(): Boolean; var Version: TWindowsVersion; begin if IsModuleLoaded('monalbumphoto.exe') then begin MsgBox(ExpandConstant('{cm:Plea

我们正在将应用程序切换到.Net4,但我们仍有Windows XP SP2上的客户。因此,我需要在设置中进行附加检查

在安装开始时弹出一条消息以丢弃XP SP2用户非常简单:

function InitializeSetup(): Boolean;
var
  Version: TWindowsVersion;
begin
  if IsModuleLoaded('monalbumphoto.exe') then begin
    MsgBox(ExpandConstant('{cm:PleaseClose}'), mbError, MB_OK);
    Result := false;
    Abort;
  end else begin
    // check Windows version (to display a better error message for XP SP2 users)
    GetWindowsVersionEx(Version);
    if (Version.Major = 5) and (Version.Minor = 1) and (Version.ServicePackMajor < 3) then begin
      MsgBox(ExpandConstant('{cm:WrongVersion}'), mbError, MB_OK);
      Result := false;
      Abort;
    end else begin
      Result := true;
    end;
  end;
end;
函数InitializeSetup():布尔值;
变量
版本:TWindowsVersion;
开始
如果IsModuleLoaded('monalbumphoto.exe'),则开始
MsgBox(ExpandConstant({cm:plesseclose}'),mbError,MB_OK);
结果:=假;
中止
结束,否则开始
//检查Windows版本(为XP SP2用户显示更好的错误消息)
GetWindowsVersionEx(版本);
如果(Version.Major=5)和(Version.Minor=1)以及(Version.ServicePackMajor<3),则开始
MsgBox(ExpandConstant({cm:errorVersion}'),mbError,MB_OK);
结果:=假;
中止
结束,否则开始
结果:=真;
结束;
结束;
结束;
但现在,要求发生了变化。我需要显示一条(有点长)消息,解释用户要么升级到SP3,要么下载我们应用程序的旧版本,并带有链接

简单的方法是将messagebox更改为使用“YESNO”按钮(如本问题中所示)自动下载设置。但我想更进一步

我想显示一个带有说明的自定义向导页面,以及一个嵌入的链接。另一个问题()显示了如何做,但看起来我只能在特定页面之后创建页面,而不能在任何页面之前创建页面

那么,是否可以在取消整个安装的任何其他页面之前显示自定义向导页面


谢谢大家!

您可以创建显示在
wpWelcome
之后的页面,并通过
ShouldSkipPage(wpWelcome)
事件函数返回true


或者,您可以跳过所有页面,直接跳转到“准备安装”页面,重新发布文本,给出说明。

多亏了@TLama,我现在有了这个,它似乎工作得很好:

// http://stackoverflow.com/questions/5461674/
function GetSystemMetrics (nIndex: Integer): Integer;
  external 'GetSystemMetrics@User32.dll stdcall setuponly';

Const
  SM_CXSCREEN = 0; // The enum-value for getting the width of the cient area for a full-screen window on the primary display monitor, in pixels.
  SM_CYSCREEN = 1; // The enum-value for getting the height of the client area for a full-screen window on the primary display monitor, in pixels.

// Download the legacy version of the software
procedure DownloadLegacyVersion(Sender : TObject);
var
  ErrorCode: Integer;
begin
  ShellExec('open', 'http://download.monalbumphoto.fr/monAlbumPhoto_XPSP2.exe', '', '', SW_SHOW, ewNoWait, ErrorCode);
end;

// Download the legacy version of the software
procedure OpenWindowsUpdate(Sender : TObject);
var
  ErrorCode: Integer;
begin
  ShellExec('open', 'http://update.microsoft.com/', '', '', SW_SHOW, ewNoWait, ErrorCode);
end;

// creates a form specifying that the user must upgrade to SP3 or download a legacy version
procedure WindowsUpgradeNeeded();
var
  Form: TSetupForm;
  StaticText: TNewStaticText;
  LinkButton, UpdateButton, OKButton: TNewButton;
begin
  Form := CreateCustomForm();
  try
    Form.ClientWidth := ScaleX(500);
    Form.ClientHeight := ScaleY(200);
    Form.Caption := ExpandConstant('{cm:WrongVersionTitle}');
    Form.BorderStyle := bsDialog;
    Form.Center();

    StaticText := TNewStaticText.Create(Form);
    StaticText.Top := ScaleY(10);
    StaticText.Left := ScaleX(10);
    StaticText.Caption := ExpandConstant('{cm:WrongVersion}');
    StaticText.AutoSize := True;
    StaticText.Parent := Form;

    LinkButton := TNewButton.Create(Form);
    LinkButton.Parent := Form;
    LinkButton.Width := ScaleX(200);
    LinkButton.Height := ScaleY(30);
    LinkButton.Left := Round(Form.ClientWidth / 2) - Round(LinkButton.Width / 2);
    LinkButton.Top := ScaleY(StaticText.Top + StaticText.Height + 10);
    LinkButton.Caption := ExpandConstant('{cm:WrongVersionDL}');
    LinkButton.OnClick := @DownloadLegacyVersion;
    LinkButton.Default := True;

    UpdateButton := TNewButton.Create(Form);
    UpdateButton.Parent := Form;
    UpdateButton.Width := ScaleX(200);
    UpdateButton.Height := ScaleY(30);
    UpdateButton.Left := Round(Form.ClientWidth / 2) - Round(LinkButton.Width / 2);
    UpdateButton.Top := ScaleY(StaticText.Top + StaticText.Height + 10 + LinkButton.Height + 10);
    UpdateButton.Caption := ExpandConstant('{cm:WrongVersionWU}');
    UpdateButton.OnClick := @OpenWindowsUpdate;
    UpdateButton.Default := True;

    OKButton := TNewButton.Create(Form);
    OKButton.Parent := Form;
    OKButton.Width := ScaleX(75);
    OKButton.Height := ScaleY(23);
    OKButton.Left := Round(Form.ClientWidth / 2) - Round(OKButton.Width / 2);
    OKButton.Top := Form.ClientHeight - ScaleY(23 + 10);
    OKButton.Caption := 'OK';
    OKButton.ModalResult := mrOk;
    OKButton.Default := False;

    Form.ActiveControl := LinkButton;

    if Form.ShowModal() = mrOk then
      MsgBox('You clicked OK.', mbInformation, MB_OK);
  finally
    Form.Free();
  end;
end;

// checks if map already running, and the minimum Windows version
function InitializeSetup(): Boolean;
var
  Version: TWindowsVersion;
begin
    // check Windows version (to display a better error message for XP SP2 users)
    GetWindowsVersionEx(Version);
    if (Version.Major = 5) and (Version.Minor = 1) and (Version.ServicePackMajor < 3) then begin
      WindowsUpgradeNeeded();
      Result := false;
    end else begin
      Result := true;
    end;
end;
//http://stackoverflow.com/questions/5461674/
函数GetSystemMetrics(nIndex:Integer):整数;
外部的GetSystemMetrics@User32.dllstdcall setuponly';
常数
SM_CXSCREEN=0;//用于获取主显示监视器上全屏窗口的cient区域宽度的枚举值,以像素为单位。
SM_CYSCREEN=1;//用于获取主显示监视器上全屏窗口的客户端区域高度的枚举值,以像素为单位。
//下载软件的旧版本
程序下载LegacyVersion(发送方:TObject);
变量
错误代码:整数;
开始
ShellExec('打开','http://download.monalbumphoto.fr/monAlbumPhoto_XPSP2.exe“,”,“SW_SHOW,ewNoWait,错误代码);
结束;
//下载软件的旧版本
过程OpenWindowsUpdate(发件人:ToObject);
变量
错误代码:整数;
开始
ShellExec('打开','http://update.microsoft.com/“,”,“SW_SHOW,ewNoWait,错误代码);
结束;
//创建一个表单,指定用户必须升级到SP3或下载旧版本
过程WindowsUpgradeRequired();
变量
表格:TSetupForm;
静态文本:TNewStaticText;
LinkButton、UpdateButton、OK按钮:TNewButton;
开始
表单:=CreateCustomForm();
尝试
Form.ClientWidth:=ScaleX(500);
Form.ClientHeight:=ScaleY(200);
Form.Caption:=ExpandConstant('{cm:ErrorVersionTitle}');
Form.BorderStyle:=bsDialog;
Form.Center();
StaticText:=TNewStaticText.Create(表单);
StaticText.Top:=ScaleY(10);
StaticText.Left:=ScaleX(10);
StaticText.Caption:=ExpandConstant('{cm:ErrorVersion}');
StaticText.AutoSize:=True;
StaticText.Parent:=表单;
LinkButton:=TNewButton.Create(表单);
LinkButton.Parent:=表单;
链接按钮宽度:=ScaleX(200);
LinkButton.高度:=ScaleY(30);
LinkButton.Left:=圆形(Form.ClientWidth/2)-圆形(LinkButton.Width/2);
LinkButton.Top:=ScaleY(StaticText.Top+StaticText.Height+10);
LinkButton.Caption:=ExpandConstant('{cm:ErrorVersionDL}');
LinkButton.OnClick:=@DownloadLegacyVersion;
LinkButton.Default:=True;
UpdateButton:=TNewButton.Create(表单);
UpdateButton.Parent:=表单;
UpdateButton.Width:=ScaleX(200);
UpdateButton.Height:=ScaleY(30);
UpdateButton.Left:=圆形(Form.ClientWidth/2)-圆形(LinkButton.Width/2);
UpdateButton.Top:=ScaleY(StaticText.Top+StaticText.Height+10+LinkButton.Height+10);
UpdateButton.Caption:=ExpandConstant(“{cm:ErrorVersionWu}”);
UpdateButton.OnClick:=@OpenWindowsUpdate;
UpdateButton.Default:=True;
确定按钮:=TNewButton.Create(表单);
OKButton.Parent:=表单;
宽度:=ScaleX(75);
确定按钮高度:=ScaleY(23);
OKButton.Left:=圆形(Form.ClientWidth/2)-圆形(OKButton.Width/2);
OKButton.Top:=Form.ClientHeight-ScaleY(23+10);
OK按钮。标题:=“OK”;
OKButton.ModalResult:=mrOk;
OK按钮。默认值:=False;
Form.ActiveControl:=LinkButton;
如果Form.showmodel()=mrOk,则
MsgBox('您单击了确定',MB信息,MB_确定);
最后
Form.Free();
结束;
结束;
//检查映射是否已在运行,以及最低Windows版本
函数InitializeSetup():Boolean;
变量
版本:TWindowsVersion;
开始
//检查Windows版本(为XP SP2用户显示更好的错误消息)
GetWindowsVersionEx(版本);
如果(Version.Major=5)和(Version.Minor=1)以及(Version.ServicePackMajor<3),则开始
WindowsUpgradeRequired();
结果:=假;
结束,否则开始
结果:=真;
结束;
结束;

该页面是否应作为安装的挡块?如果是这样的话,我就不会使用向导页面了。它可能会误导用户,而不是谈论为隐藏“下一步”按钮而必须进行的修改。有一个选项,使一个常规的形式(窗口),其中可能包含任何你能想到的。谢谢你,这将做得很好(我没有看到这个选项…)!很遗憾,我无法将您的评论标记为“