Inno - customizable page before anything else

We are translating our application to .Net4, but we still have clients in Windows XP SP2. Therefore, I need to do additional checks in the setup.

Creating a pop-up message at the beginning of the setup to throw XP SP2 users is pretty simple:

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;

But now the requirements have changed. I need to show a (long) message, explaining that the user must either upgrade to SP3 or download an outdated version of our application with a link to it.

The easiest way is to change the message box to use the YESNO buttons (for example, in this question How to display a hyperlink in Inno Setup? ) To automatically load the settings. But I want to go further.

. ( Inno Setup) , , , , .

, , ?

!

+3
2

@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;
+1

, wpWelcome, true ShouldSkipPage(wpWelcome).

" " retunr.

+1

All Articles