1

I try to use same installer for both (fresh installation and update).

  • so if user try to install my application for first time it will run the full installation included MySQL installer as prerequisites, and the part of MySQL installation within [Code] will execute normally.
  • but, if user already installed my application, and the installer is newer version (update), the part of MySQL installation within [Code] shouldn't be execute.

So, how to implement exception function for this part of code (MySQL installation) if the installation is just updating?

[Code]

procedure CurStepChanged(CurStep: TSetupStep);
{ ... }
begin
  if CurStep = ssPostInstall then
  begin
    { fresh installation code }
  end;
end;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
M.A_55
  • 135
  • 17

1 Answers1

2

You can use IsUpgrade function from my answer to
Can Inno Setup respond differently to a new install and an update?:

Though as it relies on a presence of "Uninstall" registry key, which already exists at the time of ssPostInstall, you have to cache its value.

var
  IsUpgradeCached: Boolean;

function InitializeSetup(): Boolean;
begin
  IsUpgradeCached := IsUpgrade;
  Result := True;
end;

procedure CurStepChanged(CurStep: TSetupStep);
{ ... }
begin
  if (CurStep = ssPostInstall) and (not IsUpgradeCached) then
  begin
    { fresh installation code }
  end;
end;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • thank you @Martin Prikryl , Can i use "IsUpgarde" Function to skip database input page too, and use same function in [files] sections ?! – M.A_55 Feb 21 '19 at 14:15
  • 1
    Sure, you can use it everywhere you need. – Martin Prikryl Feb 21 '19 at 14:16
  • I try the solution as you describe above, but it didn't work, and I posted a new question in details here, https://stackoverflow.com/q/56132550/10745484 @Martin Prikryl – M.A_55 May 19 '19 at 04:45
  • OK, sorry, it does not work in `ssPostInstall`. I've updated my answer. – Martin Prikryl May 19 '19 at 06:25
  • 1
    sorry for being late, i just had some issues in code, but after i solved it, your updated code run perfectly. @Martin Prikryl – M.A_55 May 23 '19 at 00:49