-
Notifications
You must be signed in to change notification settings - Fork 8
/
example3 1.0.iss
221 lines (184 loc) · 7.01 KB
/
example3 1.0.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#define MyAppName "My Program"
#define MyAppVerName "My Program 1.0"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "http://www.mycompany.com"
[Setup]
AppName={#MyAppName}
AppVerName={#MyAppVerName}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename=example3 1.0
Compression=lzma
SolidCompression=true
CreateAppDir=true
ShowLanguageDialog=yes
; We compare the setup version information here against
; the one on the server to check for a newer version.
; So to create a new version of your installer, just
; increase these numbers
VersionInfoVersion=1.0
VersionInfoTextVersion=1.0
[Languages]
Name: english; MessagesFile: compiler:Default.isl
#include ReadReg(HKEY_LOCAL_MACHINE,'Software\Sherlock Software\InnoTools\Downloader','ScriptPath','');
[Code]
{ This demo performs two downloads, one without ITD's GUI, and one with. It checks a website to
find out what the most recent version of the installer is, and offers to download the new installer
for the user.
}
procedure ExitProcess(exitCode:integer);
external '[email protected] stdcall';
var progress:TOutputProgressWizardPage;
var
NewInstallerPath:string;
procedure DownloadFinished(downloadPage:TWizardPage);
var ErrorCode:integer;
(* text:string; *)
begin
(*
Tell the user about the location of the new installer. The message is pretty ugly if
NewInstallerPath is left at the default (The {tmp} directory)
text:=ITD_GetString(ITDS_Update_WillLaunchWithPath);
StringChangeEx(text, '%1', NewInstallerPath, true);
MsgBox(text, mbInformation, MB_OK);
*)
MsgBox(ITD_GetString(ITDS_Update_WillLaunch), mbInformation, MB_OK);
if ShellExec('open', NewInstallerPath, '/updated',
ExtractFilePath(NewInstallerPath), SW_SHOW, ewNoWait, ErrorCode) then
ExitProcess(1);
end;
{ Compare the version string 'this' against the version string 'that'. A version
string looks like: 1.3.2.100. Or possibly truncated: 1.3.
Returns a positive number if this>that, 0 if this=that and a negative number
if this<that.
}
function CompareVersions(this, that:string):integer;
var thisField, thatField:integer;
begin
while (length(this)>0) or (length(that)>0) do begin
if (pos('.',this)>0) then begin
//Read the first field from the string
thisField:=StrToIntDef(Copy(this, 1, pos('.',this)-1),0);
//Remove the first field from the string
this:=Copy(this, pos('.',this)+1, length(this));
end else begin
thisField:=StrToIntDef(this, 0);
this:='';
end;
if (pos('.',that)>0) then begin
//Read the first field from the string
thatField:=StrToIntDef(Copy(that, 1, pos('.',that)-1),0);
//Remove the first field from the string
that:=Copy(that, pos('.',that)+1, length(that));
end else begin
thatField:=StrToIntDef(that, 0);
that:='';
end;
if thisField>thatField then begin
result:=1;
exit;
end else if thisField<thatField then begin
result:=-1;
exit;
end;
end;
result:=0;
end;
procedure InitializeWizard();
var
downloadPage:TWizardpage;
begin
itd_init;
//Where the new installer should be saved to, can be anywhere.
NewInstallerPath:=ExpandConstant('{tmp}\NewInstaller.exe');
{Create our own progress page for the initial download of a small
textfile from the server which says what the latest version is}
progress:=CreateOutputProgressPage(ITD_GetString(ITDS_Update_Caption),
ITD_GetString(ITDS_Update_Description));
//Create the ITD GUI so that we have it if we decide to download a new intaller version
downloadPage:=itd_downloadafter(wpWelcome);
{If the download succeeds, we will need to launch the new installer. The
callback is called if the download is successful.}
itd_afterSuccess:=@downloadfinished;
{If the download of the new installer fails, we still want to give the
user the option of continuing with the original installation}
itd_setoption('UI_AllowContinue','1');
end;
function NextButtonClick(curPageID:integer):boolean;
var
list, line:TStringList;
newavail:boolean;
i:integer;
ourVersion:string;
checkedSuccessfully:boolean;
text:string;
begin
result:=true;
if curPageID=wpWelcome then begin
//Are we being called by an updating setup? If so, don't ask to check for updates again!
for i:=1 to ParamCount do begin
if uppercase(ParamStr(i))='/UPDATED' then begin
exit;
end;
end;
//Offer to check for a new version for the user..
if MsgBox(ITD_GetString(ITDS_Update_WantToCheck), mbConfirmation, MB_YESNO) = IDYES then
begin
wizardform.show;
progress.Show;
progress.SetText(ITD_GetString(ITDS_Update_Checking),'');
progress.SetProgress(2,10);
try
newavail:=false;
checkedSuccessfully:=false;
GetVersionNumbersString(expandconstant('{srcexe}'), ourVersion);
if itd_downloadfile('http://www.sherlocksoftware.org/innotools/latestver.txt',expandconstant('{tmp}\latestver.txt'))=ITDERR_SUCCESS then begin
{ Now read the version from that file and see if it is newer.
The file has a really simple format:
2.0,"http://www.sherlocksoftware.org/innotools/example3%202.0.exe"
The installer version, a comma, and the URL where the new version can be downloaded.
}
list:=TStringList.create;
try
list.loadfromfile(expandconstant('{tmp}\latestver.txt'));
if list.count>0 then begin
line:=TStringList.create;
try
line.commatext:=list[0]; //Break down the line into its components
if line.count>=2 then begin
checkedSuccessfully:=true;
if CompareVersions(trim(line[0]), trim(ourVersion))>0 then begin
//Version is newer
text:=ITD_GetString(ITDS_Update_NewAvailable);
StringChangeEx(text, '%1', ourVersion, true); //"Current version" part of the string
StringChangeEx(text, '%2', line[0], true); //"New version" part of the string
if MsgBox(text, mbConfirmation, MB_YESNO)=IDYES then begin
itd_addFile(trim(line[1]), NewInstallerPath);
end;
end else begin
MsgBox(ITD_GetString(ITDS_Update_NoNewAvailable), mbInformation, MB_OK);
end;
end;
finally
line.free;
end;
end;
finally
list.free;
end;
end;
if not checkedSuccessfully then begin
text:=ITD_GetString(ITDS_Update_Failed);
StringChangeEx(text, '%1', ourVersion, true);
MsgBox(text, mbInformation, MB_OK);
end;
finally
progress.Hide;
end;
end;
end;
end;