forked from simulationcraft/simc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSetupSimc.iss
executable file
·171 lines (159 loc) · 5.13 KB
/
SetupSimc.iss
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
;#define SimcAppName "Simulationcraft(64)"
;#define SimcAppVersion "701-01"
;#define RealAppVersion "7.0.1.01"
#define MyAppPublisher "Simulationcraft"
#define MyAppURL "http://www.simulationcraft.org"
;#define SimcAppExeName "SimulationCraft64.exe"
[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={{AC025546-B7C5-45A7-B16A-80AE482CBB01}
AppName={#SimcAppName}
AppVersion={#SimcAppFullVersion}
;AppVerName={#SimcAppName} {#SimcAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={sd}\{#SimcAppName}\{#SimcAppVersion}
DefaultGroupName={#SimcAppName}
AllowNoIcons=yes
OutputBaseFilename="SimcSetup-{#SimcAppVersion}-{#SimcReleaseSuffix}"
SetupIconFile="{#SimcIconFile}"
Compression=lzma
SolidCompression=yes
OutputDir="{#SimcOutputDir}"
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1
[Files]
Source: "{#SimcReleaseDir}\{#SimcAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#SimcReleaseDir}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Dirs]
Name:"{app}\"; Permissions:everyone-modify
[Icons]
Name: "{group}\{#SimcAppName}"; Filename: "{app}\{#SimcAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#SimcAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#SimcAppName}"; Filename: "{app}\{#SimcAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#SimcAppName}"; Filename: "{app}\{#SimcAppExeName}"; Tasks: quicklaunchicon
[Run]
Filename: "{app}\{#SimcAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(SimcAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
[Code]
function GetNumber(var temp: String): Integer;
var
part: String;
pos1: Integer;
begin
if Length(temp) = 0 then
begin
Result := -1;
Exit;
end;
pos1 := Pos('.', temp);
if (pos1 = 0) then
begin
Result := StrToInt(temp);
temp := '';
end
else
begin
part := Copy(temp, 1, pos1 - 1);
temp := Copy(temp, pos1 + 1, Length(temp));
Result := StrToInt(part);
end;
end;
function CompareInner(var temp1, temp2: String): Integer;
var
num1, num2: Integer;
begin
num1 := GetNumber(temp1);
num2 := GetNumber(temp2);
if (num1 = -1) or (num2 = -1) then
begin
Result := 0;
Exit;
end;
if (num1 > num2) then
begin
Result := 1;
end
else if (num1 < num2) then
begin
Result := -1;
end
else
begin
Result := CompareInner(temp1, temp2);
end;
end;
function CompareVersion(str1, str2: String): Integer;
var
temp1, temp2: String;
begin
temp1 := str1;
temp2 := str2;
Result := CompareInner(temp1, temp2);
end;
function InitializeSetup(): Boolean;
var
oldVersion: String;
uninstaller: String;
ErrorCode: Integer;
vCurID :String;
vCurAppName :String;
begin
vCurID:= '{#SetupSetting("AppId")}';
vCurAppName:= '{#SetupSetting("AppName")}';
//remove first "{" of ID
vCurID:= Copy(vCurID, 2, Length(vCurID) - 1);
//
if RegKeyExists(HKEY_LOCAL_MACHINE,
'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + vCurID + '_is1') then
begin
RegQueryStringValue(HKEY_LOCAL_MACHINE,
'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + vCurID + '_is1',
'DisplayVersion', oldVersion);
if (CompareVersion(oldVersion, '{#SetupSetting("AppVersion")}') > 0) then
begin
if MsgBox('Version ' + oldVersion + ' of ' + vCurAppName + ' is already installed. Would you like to install this older version?',
mbConfirmation, MB_YESNO) = IDNO then
begin
Result := False;
end
else
begin
Result := True;
end;
end
else
begin
if (CompareVersion(oldVersion, '{#SetupSetting("AppVersion")}') < 0 ) then
begin
if MsgBox('Would you like to uninstall the older version?',
mbConfirmation, MB_YESNO) = IDNO then
begin
Result := True;
end
else
begin
RegQueryStringValue(HKEY_LOCAL_MACHINE,
'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + vCurID + '_is1',
'UninstallString', uninstaller);
ShellExec('runas', uninstaller, '/SILENT', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
Result := True;
end
end;
Result := True;
end
end
else
begin
Result := True;
end;
end;