1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| ; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppPath "D:\mes_programmes\my_club\output\"
#define MyAppName "My Club"
#define MyAppNameUnder "my_club"
#define MyVersion GetFileVersion(MyAppPath + MyAppNameUnder + ".vmp.exe")
#define MyAppId "{CA45C15E-0FDC-48C3-A4CB-92E76C70F512}"
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{#MyAppId}
[Code]
// -- renvoie à un numéro de version segmentée sans .
function CutToThis(var StrVersion: String): Integer;
var
WhereDot: Integer;
begin
//Trouve la position du premier .
WhereDot := Pos('.', StrVersion);
//si aucun . est trouvé on renvoie le résultat sous forme de integer
if WhereDot = 0 then
Result := StrToInt(StrVersion)
else
begin
//sinon on renvoie le numéro jusqu'au . sous forme de integer
Result := StrToInt(Copy(StrVersion, 0, WhereDot - 1));
//puis on enlève la partie renvoyée ainsi que le . De la chaîne passé en paramètres
StrVersion := Copy(StrVersion, WhereDot + 1, Length(StrVersion));
end;
end;
// -- on start install check version instaled
function InitializeSetup(): Boolean;
var
InstalledVersion, ActualVersion: String;
IV1, IV2, IV3, IV4, AV1, AV2, AV3, AV4: Integer;
begin
Result := True;
// -- take number of version installed with .
if not RegQueryStringValue( HKLM, 'Software\Microsoft\Windows\CurrentVersion\Uninstall\{#MyAppId}_is1', 'DisplayVersion', InstalledVersion) then
InstalledVersion := '0.0.0.0';
// -- transform string version installed to 4 int number without .
IV1 := CutToThis(InstalledVersion);
IV2 := CutToThis(InstalledVersion);
IV3 := CutToThis(InstalledVersion);
IV4 := CutToThis(InstalledVersion);
// -- transform string version to install to 4 int number without .
ActualVersion := '{#MyVersion}';
AV1 := CutToThis(ActualVersion);
AV2 := CutToThis(ActualVersion);
AV3 := CutToThis(ActualVersion);
AV4 := CutToThis(ActualVersion);
// -- if old is installed show warn and stop install
If (IV1 < AV1) Or
((IV1 = AV1) And (IV2 < AV2)) Or
((IV1 = AV1) And (IV2 = AV2) And (IV3 < AV3)) Or
((IV1 = AV1) And (IV2 = AV2) And (IV3 = AV3) And (IV4 < AV4)) Then
Begin
MsgBox( 'Une ancienne version de {#MyAppName} est déjà installé.', mbError, MB_OK);
Result := false;
Exit;
End;
end; |
Partager