Skip to content

Instantly share code, notes, and snippets.

@rwilkes
Forked from mistic100/check-version.iss
Created April 26, 2018 02:04
Show Gist options
  • Save rwilkes/11faa34bac787a0707a35a69cf4a37c8 to your computer and use it in GitHub Desktop.
Save rwilkes/11faa34bac787a0707a35a69cf4a37c8 to your computer and use it in GitHub Desktop.
[InnoSetup] Prevent install if newer version is already installed
#define AppId "{INSERT HERE YOUR GUID}"
#define AppName "My App"
#define AppVersion "1.7"
[CustomMessages]
english.NewerVersionExists=A newer version of {#AppName} is already installed.%n%nInstaller version: {#AppVersion}%nCurrent version:
[Code]
// find current version before installation
function InitializeSetup: Boolean;
var Version: String;
begin
if RegValueExists(HKEY_LOCAL_MACHINE,'Software\Microsoft\Windows\CurrentVersion\Uninstall\{#AppId}_is1', 'DisplayVersion') then
begin
RegQueryStringValue(HKEY_LOCAL_MACHINE,'Software\Microsoft\Windows\CurrentVersion\Uninstall\{#AppId}_is1', 'DisplayVersion', Version);
if Version > '{#AppVersion}' then
begin
MsgBox(ExpandConstant('{cm:NewerVersionExists} '+Version), mbInformation, MB_OK);
Result := False;
end
else
begin
Result := True;
end
end
else
begin
Result := True;
end
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment