Created
July 27, 2012 02:10
-
-
Save lextm/3185817 to your computer and use it in GitHub Desktop.
Inno Setup script sample part 2
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
function InitializeSetup(): Boolean; | |
var | |
oldVersion: String; | |
uninstaller: String; | |
ErrorCode: Integer; | |
begin | |
if RegKeyExists(HKEY_LOCAL_MACHINE, | |
'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{F768F6BA-F164-4599-BC26-DCCFC2F76855}_is1') then | |
begin | |
RegQueryStringValue(HKEY_LOCAL_MACHINE, | |
'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{F768F6BA-F164-4599-BC26-DCCFC2F76855}_is1', | |
'DisplayVersion', oldVersion); | |
if (CompareVersion(oldVersion, '6.0.0.1004') < 0) then | |
begin | |
if MsgBox('Version ' + oldVersion + ' of Code Beautifier Collection is already installed. Continue to use this old version?', | |
mbConfirmation, MB_YESNO) = IDYES then | |
begin | |
Result := False; | |
end | |
else | |
begin | |
RegQueryStringValue(HKEY_LOCAL_MACHINE, | |
'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{F768F6BA-F164-4599-BC26-DCCFC2F76855}_is1', | |
'UninstallString', uninstaller); | |
ShellExec('runas', uninstaller, '/SILENT', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode); | |
Result := True; | |
end; | |
end | |
else | |
begin | |
MsgBox('Version ' + oldVersion + ' of Code Beautifier Collection is already installed. This installer will exit.', | |
mbInformation, MB_OK); | |
Result := False; | |
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