-
Notifications
You must be signed in to change notification settings - Fork 2
/
Setup.iss
254 lines (225 loc) · 8.03 KB
/
Setup.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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define ApplicationName 'ESP8266 Wizard'
#define ApplicationVersion '1.4.3'
#define OldAppId '{3793A16D-841C-4E6C-931B-9D5AD44410C9}'
#define Revision 'OpenSource (1.0)'
#define SourceURL 'https://github.com/fsmoke/ESP8266-Wizard-Package'
[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={#ApplicationName}
AppName={#ApplicationName}
AppVersion={#ApplicationVersion}
AppPublisher=Mathieu St-Laurent - Relentless research lab
DefaultDirName={pf}\Relentless.rad\ESP8266Wizard
DisableDirPage=false
DisableProgramGroupPage=yes
OutputDir=Release
OutputBaseFilename={#ApplicationName} {#ApplicationVersion} - {#Revision}
SetupIconFile=ESPressif.ico
UninstallDisplayIcon=ESPressif.ico
Compression=lzma
SolidCompression=yes
WizardImageFile=WIFI.bmp
WizardSmallImageFile=WIFISmall.bmp
[Languages]
Name: english; MessagesFile: compiler:Default.isl
[Files]
Source: Distrib\*; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs
Source: Temp\bin\ESP8266Wizard\Release\ESP8266Wizard.vsix; DestDir: {app}; Flags: ignoreversion
[Run]
[UninstallRun]
[Code]
var
LicenseLinkLabel: TLabel;
//VSOptionsPage: TInputOptionWizardPage;
VSIXInstallerPaths: TStrings;
VSVersions: TStrings;
//procedure ClickVSVersions(Sender: TObject);
//var
// i: Integer;
// f: Boolean;
//begin
// f := False;
// for i := 0 to VSOptionsPage.CheckListBox.Items.Count - 1 do
// if (VSOptionsPage.Values[i]) then
// begin
// f := True;
// break;
// end;
// Wizardform.NextButton.Enabled := f;
//end;
[Code]
function AllocConsole(
): BOOL;
external '[email protected] stdcall';
procedure FillVsVersions();
var
sRegKey: String;
sRegValue: String;
sTmpFileName: String;
sExecStdout: AnsiString;
ResultCode: integer;
begin
//check vs2017
sRegKey := 'VisualStudio.DTE.15.0';
if (RegKeyExists(HKCR, sRegKey)) then
begin
sRegKey := 'SOFTWARE\Microsoft\VisualStudio\SxS\VS7';
if (RegQueryStringValue(HKLM, sRegKey, '15.0', sRegValue)) then
begin
VSVersions.Add('VS2017');
VSIXInstallerPaths.Add(sRegValue + 'Common7\IDE\');
end;
end;
//check vs2019
sRegKey := 'VisualStudio.DTE.16.0';
if (RegKeyExists(HKCR, sRegKey)) then
begin
//for debug
//AllocConsole();
sTmpFileName := ExpandConstant('{tmp}') + '\vswhere_results.txt';
sRegKey := ExpandConstant('{cmd}');
if Exec(ExpandConstant('{cmd}'),
'/S /C ""' + ExpandConstant('{commonpf32}') + '\Microsoft Visual Studio\Installer\vswhere.exe" ' +
'-latest -prerelease -products * -property enginePath > "' + sTmpFileName + '""',
'', SW_HIDE,
ewWaitUntilTerminated, ResultCode) then
begin
if LoadStringFromFile(sTmpFileName, sExecStdout) then
begin
while (sExecStdout[length(sExecStdout)] = #$A) or (sExecStdout[length(sExecStdout)] = #$D) do
Delete(sExecStdout,length(sExecStdout), 1);
VSVersions.Add('VS2019');
VSIXInstallerPaths.Add(sExecStdout + '\');
end;
DeleteFile(sTmpFileName);
end;
end;
end;
procedure OpenBrowser(Url: string);
var
ErrorCode: Integer;
begin
ShellExec('open', Url, '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;
procedure SourcesLinkClick(Sender: TObject);
begin
OpenBrowser('{#SourceURL}');
end;
procedure InitializeWizard;
var
//i,ind: Integer;
SourcesLink: TLabel;
begin
LicenseLinkLabel := TLabel.Create(WizardForm);
LicenseLinkLabel.Parent := WizardForm;
LicenseLinkLabel.Left := 8;
LicenseLinkLabel.Top := WizardForm.ClientHeight - LicenseLinkLabel.ClientHeight - 32;
LicenseLinkLabel.Caption := '{#SetupSetting("AppPublisher")}' + #13#10 + 'Revision by : {#Revision}';
SourcesLink := TLabel.Create(WizardForm);
SourcesLink.Parent := WizardForm;
SourcesLink.Left := LicenseLinkLabel.Left;
SourcesLink.Top := LicenseLinkLabel.Top + LicenseLinkLabel.Height;
SourcesLink.Caption := 'Get source code';
SourcesLink.OnClick := @SourcesLinkClick;
SourcesLink.ParentFont := True;
SourcesLink.Font.Style := SourcesLink.Font.Style + [fsUnderline, fsBold];
SourcesLink.Font.Color := clBlue;
SourcesLink.Cursor := crHand;
//VSOptionsPage := CreateInputOptionPage(wpSelectComponents,
// 'Visual Studio version', 'Select version of Visual Studio', 'Select version of Visual Studio', false, false);
//VSOptionsPage.CheckListBox.OnClickCheck := @ClickVSVersions;
//VSOptionsPage.CheckListBox.Enabled := False;
//for i := 0 to VSVersions.Count - 1 do
//begin
// ind := VSOptionsPage.Add(VSVersions[i]);
// VSOptionsPage.Values[ind] := True;
//end;
end;
function InitializeSetup: Boolean;
var
sRegKey: String;
sUnInstall: String;
sVersion: String;
Prompt: Integer;
//OLD Versions are deprecated
//VSIXBefore: Boolean;
begin
VSIXInstallerPaths := TStringList.Create();
VSVersions := TStringList.Create();
FillVsVersions();
sRegKey := 'Software\Microsoft\Windows\CurrentVersion\Uninstall\{#OldAppId}_is1';
if (RegQueryStringValue(HKLM, sRegKey, 'UninstallString', sUnInstall)) then
RegQueryStringValue(HKLM, sRegKey, 'DisplayVersion', sVersion);
sRegKey := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#SetupSetting("AppId")}_is1');
if (RegQueryStringValue(HKLM, sRegKey, 'UninstallString', sUnInstall)) then
RegQueryStringValue(HKLM, sRegKey, 'DisplayVersion', sVersion);
if (sUnInstall <> '') then
begin
if (sVersion > '{#SetupSetting("AppVersion")}') then
begin
MsgBox('Current version of ESP8266 Wizard was newer.'#13'Install will be canceled', mbInformation, MB_OK);
Result:= False;
end else
begin
//OLD Versions are deprecated
//VSIXBefore:=False;
//if (sVersion < '1.2.3') then VSIXBefore:=True;
if (sVersion = '{#SetupSetting("AppVersion")}') then
Prompt:= MsgBox(ExpandConstant('Same version was detected. Do you want to reinstall it?'), mbInformation, MB_YESNO)
else
Prompt:= MsgBox(ExpandConstant('An older version was detected. Do you want to uninstall it?'), mbInformation, MB_YESNO);
if (Prompt = IDYES) then
begin
sUnInstall:= RemoveQuotes(sUnInstall);
Exec(ExpandConstant(sUnInstall), '/SILENT', '', SW_SHOW, ewWaitUntilTerminated, Prompt);
//OLD Versions are deprecated
//if (VSIXBefore) then
//begin
// ExtractTemporaryFiles('{app}\VSIXInstaller.exe*');
// ExtractTemporaryFiles('{app}\VSIXAssemblies\*');
// ExtractTemporaryFiles('{app}\PkgdefMgmt.dll');
// ExtractTemporaryFiles('{app}\VSHiveStub.exe');
// Exec(ExpandConstant('{tmp}\')+'{app}\VSIXInstaller', '/uninstall:"ESP8266Wizard.Mathieu St-Laurent.2369a963-05dc-4156-8143-c93633763702"', '', SW_SHOW, ewWaitUntilTerminated, Prompt);
//end;
Result:= True;
end else
Result:= False;
end
end else
Result:= True;
end;
function PrepareToInstall(var NeedsRestart: Boolean): String;
var
Prompt: Integer;
begin
NeedsRestart := False;
if (VSIXInstallerPaths.Count > 0) then
begin
//MsgBox(VSIXInstallerPaths[0], mbInformation, MB_OK);
ExtractTemporaryFiles('{app}\ESP8266Wizard.vsix');
//MsgBox(ExpandConstant('{tmp}\')+'{app}\ESP8266Wizard.vsix', mbInformation, MB_OK);
Exec(VSIXInstallerPaths[0] + 'VSIXInstaller',
ExpandConstant('{tmp}\')+'{app}\ESP8266Wizard.vsix',
'', SW_SHOW, ewWaitUntilTerminated, Prompt);
end;
Result:= '';
end;
function InitializeUninstall: Boolean;
var
Prompt: Integer;
begin
VSIXInstallerPaths := TStringList.Create();
VSVersions := TStringList.Create();
FillVsVersions();
if (VSIXInstallerPaths.Count > 0) then
begin
Exec(VSIXInstallerPaths[0] + 'VSIXInstaller',
'/uninstall:"ESP8266Wizard.Mathieu St-Laurent.2369a963-05dc-4156-8143-c93633763702"',
'', SW_SHOW, ewWaitUntilTerminated, Prompt);
end;
Result:= True;
end;