Mark Sowards
Mark Sowards

Reputation: 171

How to get Inno setup to display message with only a cancel button so the install stops

I'm using Inno setup to deliver a software package. It detects the version of Access and pops up a message. I want to make the message tell the user they have downloaded the wrong version and halt the installation. Currently the Inno script uses

itd_downloadafter(NoRuntimePage.ID);

to display a message telling the user they need the AccessRuntime installed. When they user presses next it downloads the AccessRuntime and continues. I want to change this for my new script to tell the user they have the wrong version and then end the install script when they press next or just cancel. Can anyone help me abit on this?

Upvotes: 2

Views: 4179

Answers (2)

John Sobolewski
John Sobolewski

Reputation: 4572

** TLama's answer is more accurate. **

You could use the InitializeWizard procedure to run the access check at the beginning... if it fails you should be able to show your message box then call Abort() .

[code]
var CustomPage: TInputQueryWizardPage;

procedure InitializeWizard;
begin;
  {your checking Access version and message box}
  Abort();
end;

Upvotes: 1

TLama
TLama

Reputation: 76663

Why to use InitializeSetup ?

If you want to conditionally exit the setup before the wizard starts, don't use InitializeWizard event function with the Abort exception raise. You'll be wasting your time, needed to create the whole wizard form. Use the InitializeSetup event function instead. There you can raise the Abort exception or better return False to its boolean result, and exit the function as was supposed to do - the final effect will be definitely the same.

Internally, the InitializeSetup function, raises just this Abort exception, when you return False to it from your script. Contrary to InitializeWizard event, when the InitializeSetup event is fired, the wizard form is not created yet, so you won't be wasting your time and never used system resources.

Code example:

In the following pseudo-code you need to have a function like UserDownloadedWrongVersion where, if you return True, the setup will be terminated, nothing happens oterwise.

[Code]
function UserDownloadedWrongVersion: Boolean;
begin
  // make your check here and return True when you detect a wrong 
  // version, what causes the setup to terminate; False otherwise
end;

function InitializeSetup: Boolean;
begin
  Result := not UserDownloadedWrongVersion;
  if not Result then
  begin
    MsgBox('You''ve downloaded the wrong version. Setup will now exit!', 
      mbError, MB_OK);
    Exit;   // <-- or use Abort; instead, but there's no need for panic
  end;
end;

Upvotes: 6

Related Questions