5

I've installed my program. But if I try to install it again, it does and the program is replaced.

I saw this question Inno Setup - How to display notifying message while installing if application is already installed on the machine?

Can I create a certain registry entry so I can check it and prevent a new installation? In this question there is some related information: Skip installation in Inno Setup if other program is not installed.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Nico Z
  • 997
  • 10
  • 33

1 Answers1

10

You do not need to create any registry key. The installer already creates a registry key for the uninstaller. You can just check that. It's the same key, that the answer to question, you refer to, uses. But you do not need to do the check for version. Just check an existence. Also you should check both the HKEY_LOCAL_MACHINE and the HKEY_CURRENT_USER:

#define AppId "myapp"

[Setup]
AppId={#AppId}

[Code]

function InitializeSetup(): Boolean;
begin
  Result := True;
  if RegKeyExists(HKEY_LOCAL_MACHINE,
       'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#AppId}_is1') or
     RegKeyExists(HKEY_CURRENT_USER,
       'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#AppId}_is1') then
  begin
    MsgBox('The application is installed already.', mbInformation, MB_OK);
    Result := False;
  end;
end;

The application is installed already


Or just reuse IsUpgrade function from Can Inno Setup respond differently to a new install and an update?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992