-
-
Save rwilkes/11faa34bac787a0707a35a69cf4a37c8 to your computer and use it in GitHub Desktop.
[InnoSetup] Prevent install if newer version is already installed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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