-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathInstaller.iss
More file actions
1001 lines (852 loc) · 33.2 KB
/
Copy pathInstaller.iss
File metadata and controls
1001 lines (852 loc) · 33.2 KB
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; Script generated by the Inno Script Studio Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "EDDI"
#define MyAppVersion "5.0.5"
#define MyAppPublisher "Elite Dangerous Community Developers (EDCD)"
#define MyAppURL "https://github.com/EDCD/EDDI/"
#define MyAppExeName "EDDI.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.)
AllowUNCPath=no
ArchitecturesAllowed=x64compatible
ArchitecturesInstallIn64BitMode=x64compatible
AppId={{830C0324-30D8-423C-B5B4-D7EE8D007A79}
AppName={#MyAppName}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
AppVerName={#MyAppName} {#MyAppVersion}
AppVersion={#MyAppVersion}
CloseApplications=yes
DefaultDirName={code:GetDefaultInstallDir}
DefaultGroupName={#MyAppName}
DirExistsWarning=no
DisableDirPage=no
DisableWelcomePage=no
LicenseFile="{#SourcePath}\LicenseFile.txt"
OutputBaseFilename={#MyAppName}-{#MyAppVersion}
OutputDir="{#SourcePath}\bin\Installer"
PrivilegesRequired=lowest
PrivilegesRequiredOverridesAllowed=dialog commandline
RestartApplications=no
SolidCompression=yes
SourceDir="{#SourcePath}\bin\Release\Application"
UninstallDisplayIcon={app}\{#MyAppExeName}
UsePreviousAppDir=no
UsePreviousTasks=no
WizardImageFile={#SourcePath}\graphics\logo.bmp
WizardSmallImageFile={#SourcePath}\graphics\logo.bmp
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "*.exe"; DestDir: "{app}"; Excludes: "DocumentationGenerator.exe"
Source: "*.exe.config"; DestDir: "{app}"; Flags: skipifsourcedoesntexist
Source: "runtimes\*.*"; DestDir: "{app}\runtimes"; Flags: recursesubdirs createallsubdirs
Source: "*.dll"; DestDir: "{app}"; Excludes: "Tests.dll,DocumentationGenerator.dll"
Source: "*.dll.config"; DestDir: "{app}"; Flags: skipifsourcedoesntexist
Source: "*.resources.dll"; DestDir: "{app}"; Flags: recursesubdirs createallsubdirs
Source: "Cottle\*.*"; DestDir: "{app}\Cottle"; Flags: recursesubdirs createallsubdirs
Source: "Wiki\*.*"; DestDir: "{app}\Wiki"; Flags: recursesubdirs createallsubdirs
Source: "eddi.json"; DestDir: "{app}"
Source: "eddi.*.json"; DestDir: "{app}"
Source: "*.md"; DestDir: "{app}"
Source: "{#SourcePath}\bin\Release\VoiceAttackPluginShim\*"; DestDir: "{code:GetVoiceAttack2EddiDir}"; Flags: recursesubdirs createallsubdirs
; Remove outdated files
[InstallDelete]
; --- Remove old architecture folders entirely ---
Type: filesandordirs; Name: "{app}\x86"
Type: filesandordirs; Name: "{app}\x64"
Type: filesandordirs; Name: "{app}\runtimes"
; --- Remove all old DLLs in the root folder ---
Type: files; Name: "{app}\*.dll"
; --- Remove old PDBs ---
Type: files; Name: "{app}\*.pdb"
; --- Remove old doc files ---
Type: files; Name: "{app}\*.md"
Type: files; Name: "{app}\*.xml"
; --- Remove old default personality files ---
Type: files; Name: "{app}\eddi.json"
Type: files; Name: "{app}\eddi.*.json"
; --- Remove old VoiceAttack profiles ---
Type: files; Name: "{app}\*.vap"
; --- Remove old resource files that may no longer be valid ---
Type: filesandordirs; Name: "{app}\*\*.resources.dll"
; --- Remove old app payload files from the VoiceAttack plugin folder before copying the new plugin ---
Type: files; Name: "{code:GetVoiceAttack2EddiDir}\*.dll"
Type: files; Name: "{code:GetVoiceAttack2EddiDir}\*.pdb"
Type: files; Name: "{code:GetVoiceAttack2EddiDir}\*.deps.json"
Type: files; Name: "{code:GetVoiceAttack2EddiDir}\*.runtimeconfig.json"
Type: files; Name: "{code:GetVoiceAttack2EddiDir}\*.exe"
Type: files; Name: "{code:GetVoiceAttack2EddiDir}\*.exe.config"
Type: filesandordirs; Name: "{code:GetVoiceAttack2EddiDir}\runtimes"
Type: filesandordirs; Name: "{code:GetVoiceAttack2EddiDir}\cs"
Type: filesandordirs; Name: "{code:GetVoiceAttack2EddiDir}\de"
Type: filesandordirs; Name: "{code:GetVoiceAttack2EddiDir}\es"
Type: filesandordirs; Name: "{code:GetVoiceAttack2EddiDir}\fr"
Type: filesandordirs; Name: "{code:GetVoiceAttack2EddiDir}\hu"
Type: filesandordirs; Name: "{code:GetVoiceAttack2EddiDir}\it"
Type: filesandordirs; Name: "{code:GetVoiceAttack2EddiDir}\ja"
Type: filesandordirs; Name: "{code:GetVoiceAttack2EddiDir}\pt-BR"
Type: filesandordirs; Name: "{code:GetVoiceAttack2EddiDir}\pt-PT"
Type: filesandordirs; Name: "{code:GetVoiceAttack2EddiDir}\ru"
Type: filesandordirs; Name: "{code:GetVoiceAttack2EddiDir}\zh-CN"
Type: filesandordirs; Name: "{code:GetVoiceAttack2EddiDir}\Cottle"
Type: filesandordirs; Name: "{code:GetVoiceAttack2EddiDir}\Wiki"
Type: files; Name: "{code:GetVoiceAttack2EddiDir}\*.md"
Type: files; Name: "{code:GetVoiceAttack2EddiDir}\eddi.json"
Type: files; Name: "{code:GetVoiceAttack2EddiDir}\eddi.*.json"
; --- Remove old config files that may no longer be valid ---
Type: files; Name: "{app}\*.dll.config"
; --- Remove old user-specific cached configs that cause runtime mismatches ---
Type: filesandordirs; Name: "{localappdata}\Eddi\Eddi.exe_*"; Check: ShouldModifyCurrentUserAreas
Type: files; Name: "{localappdata}\Eddi\Eddi.exe_*\*\user.config"; Check: ShouldModifyCurrentUserAreas
; --- Remove obsolete legacy files from older EDDI versions ---
Type: files; Name: "{app}\*.exe"
Type: files; Name: "{app}\*.exe.config"
Type: files; Name: "{app}\EDDI.ico"
Type: files; Name: "{userappdata}\EDDI\credentials.json"; Check: ShouldModifyCurrentUserAreas
Type: files; Name: "{userappdata}\EDDI\elite.json"; Check: ShouldModifyCurrentUserAreas
Type: filesandordirs; Name: "{userappdata}\EDDI\galnet"; Check: ShouldModifyCurrentUserAreas
; Remove sensitive data on uninstall
[UninstallDelete]
Type: files; Name: "{userappdata}\EDDI\CompanionAPI.json"; Check: ShouldModifyCurrentUserAreas
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon; Check: IsAdminInstallMode
Name: "{userdesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon; Check: not IsAdminInstallMode
[Run]
; Manual / non-silent installer launch option.
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent runasoriginaluser
; Silent in-app upgrade launch.
; This always launches the newly installed executable.
Filename: "{app}\{#MyAppExeName}"; Flags: nowait skipifnotsilent runasoriginaluser; Check: ShouldRunAfterInAppUpgrade
[Messages]
SelectDirBrowseLabel=To continue, click Next. If this is not where you want the EDDI application files installed, click Browse. Do not select a VoiceAttack Apps folder.
[Registry]
Root: "HKLM"; Subkey: "Software\Classes\eddi"; ValueType: string; ValueData: "EDDI URL Protocol"; Flags: uninsdeletekey; Check: ShouldWriteMachineRegistry
Root: "HKLM"; Subkey: "Software\Classes\eddi"; ValueType: string; ValueName: "URL Protocol"; Flags: uninsdeletekey; Check: ShouldWriteMachineRegistry
Root: "HKLM"; Subkey: "Software\Classes\eddi\Default Icon"; ValueType: string; ValueData: "{app}\{#MyAppExeName},0"; Flags: uninsdeletekey; Check: ShouldWriteMachineRegistry
Root: "HKLM"; Subkey: "Software\Classes\eddi\shell\open\command"; ValueType: string; ValueData: """{app}\{#MyAppExeName}"" ""%1"""; Flags: uninsdeletekey; Check: ShouldWriteMachineRegistry
Root: "HKLM"; Subkey: "Software\Classes\eddi\shell\open\ddeexec"; ValueType: string; ValueData: "%1"; Flags: uninsdeletekey; Check: ShouldWriteMachineRegistry
Root: "HKCU"; Subkey: "Software\Classes\eddi"; ValueType: string; ValueData: "EDDI URL Protocol"; Flags: uninsdeletekey; Check: ShouldWriteCurrentUserRegistry
Root: "HKCU"; Subkey: "Software\Classes\eddi"; ValueType: string; ValueName: "URL Protocol"; Flags: uninsdeletekey; Check: ShouldWriteCurrentUserRegistry
Root: "HKCU"; Subkey: "Software\Classes\eddi\Default Icon"; ValueType: string; ValueData: "{app}\{#MyAppExeName},0"; Flags: uninsdeletekey; Check: ShouldWriteCurrentUserRegistry
Root: "HKCU"; Subkey: "Software\Classes\eddi\shell\open\command"; ValueType: string; ValueData: """{app}\{#MyAppExeName}"" ""%1"""; Flags: uninsdeletekey; Check: ShouldWriteCurrentUserRegistry
Root: "HKCU"; Subkey: "Software\Classes\eddi\shell\open\ddeexec"; ValueType: string; ValueData: "%1"; Flags: uninsdeletekey; Check: ShouldWriteCurrentUserRegistry
Root: "HKCU"; Subkey: "Software\EDCD\EDDI"; ValueType: string; ValueName: "ExecutablePath"; ValueData: "{app}\{#MyAppExeName}"; Check: ShouldWriteCurrentUserRegistry
Root: "HKCU"; Subkey: "Software\EDCD\EDDI"; ValueType: string; ValueName: "InstallDirectory"; ValueData: "{app}"; Check: ShouldWriteCurrentUserRegistry
Root: "HKCU"; Subkey: "Software\EDCD\EDDI"; ValueType: string; ValueName: "Version"; ValueData: "{#MyAppVersion}"; Check: ShouldWriteCurrentUserRegistry
Root: "HKLM"; Subkey: "Software\EDCD\EDDI"; ValueType: string; ValueName: "ExecutablePath"; ValueData: "{app}\{#MyAppExeName}"; Check: ShouldWriteMachineLocator
Root: "HKLM"; Subkey: "Software\EDCD\EDDI"; ValueType: string; ValueName: "InstallDirectory"; ValueData: "{app}"; Check: ShouldWriteMachineLocator
Root: "HKLM"; Subkey: "Software\EDCD\EDDI"; ValueType: string; ValueName: "Version"; ValueData: "{#MyAppVersion}"; Check: ShouldWriteMachineLocator
[Code]
var
LegacySilentMigration: Boolean;
VoiceAttackAppsPage: TWizardPage;
ApplicationDirText: TNewStaticText;
VoiceAttackAppsDirEdit: TNewEdit;
VoiceAttackPluginDirText: TNewStaticText;
VoiceAttackAppsBrowseButton: TNewButton;
SelectedVoiceAttackAppsDir: string;
function NormalizePath(const S: string): string;
begin
Result := Lowercase(RemoveBackslashUnlessRoot(S));
end;
function SamePath(const A, B: string): Boolean;
begin
Result := NormalizePath(A) = NormalizePath(B);
end;
function IsUnderPath(const Child, Parent: string): Boolean;
var
C, P: string;
begin
C := NormalizePath(Child);
P := NormalizePath(Parent);
Result := (C = P) or (Pos(P + '\', C) = 1);
end;
function IsUserProfilePath(const Dir: string): Boolean;
var
UserProfile: string;
begin
UserProfile := GetEnv('USERPROFILE');
Result :=
IsUnderPath(Dir, ExpandConstant('{localappdata}')) or
IsUnderPath(Dir, ExpandConstant('{userappdata}')) or
((Trim(UserProfile) <> '') and IsUnderPath(Dir, UserProfile));
end;
function TryGetVoiceAttack2AppsDir(var Dir: string): Boolean;
var
VAFolder: string;
begin
Result := False;
if RegQueryStringValue(
HKCU,
'Software\VoiceAttack.com\VoiceAttack2\LastRun',
'AppsFolder',
Dir) and (Trim(Dir) <> '') then
begin
Dir := RemoveBackslashUnlessRoot(Dir);
Result := True;
exit;
end;
if RegQueryStringValue(
HKCU,
'Software\VoiceAttack.com\VoiceAttack2\LastRun',
'VAFolder',
VAFolder) and (Trim(VAFolder) <> '') then
begin
Dir := AddBackslash(RemoveBackslashUnlessRoot(VAFolder)) + 'Apps';
Result := True;
end;
end;
function TryGetLegacyVoiceAttackAppsDir(var Dir: string): Boolean;
var
VAFolder: string;
begin
Result := False;
if RegQueryStringValue(
HKCU,
'Software\VoiceAttack.com\VoiceAttack\LastRun',
'AppsFolder',
Dir) and (Trim(Dir) <> '') then
begin
Dir := RemoveBackslashUnlessRoot(Dir);
Result := True;
exit;
end;
if RegQueryStringValue(
HKCU,
'Software\VoiceAttack.com\VoiceAttack\LastRun',
'VAFolder',
VAFolder) and (Trim(VAFolder) <> '') then
begin
Dir := AddBackslash(RemoveBackslashUnlessRoot(VAFolder)) + 'Apps';
Result := True;
end;
end;
function NormalizeVoiceAttackAppsDir(const Dir: string): string;
var
CleanDir: string;
ParentDir: string;
begin
CleanDir := RemoveBackslashUnlessRoot(Dir);
ParentDir := RemoveBackslashUnlessRoot(ExtractFileDir(CleanDir));
if (Lowercase(ExtractFileName(CleanDir)) = Lowercase('{#MyAppName}')) and
(Lowercase(ExtractFileName(ParentDir)) = 'apps') then
begin
Result := ParentDir;
exit;
end;
Result := CleanDir;
end;
function GetPerUserVoiceAttackAppsDir: string;
begin
Result := ExpandConstant('{userappdata}\VoiceAttack2\Apps');
end;
function ShouldUseDetectedVoiceAttackAppsDirAsDefault(const Dir: string): Boolean;
begin
{
In current-user install mode, avoid defaulting to a shared VoiceAttack Apps
folder from LastRun. That creates a mixed per-user app / shared plugin install
which validation must reject because the shared plugin would point at one
user's private application directory.
}
Result := IsAdminInstallMode or IsUserProfilePath(Dir);
end;
function GetDefaultVoiceAttackAppsDir: string;
var
AppsFolder: string;
begin
if TryGetVoiceAttack2AppsDir(AppsFolder) and ShouldUseDetectedVoiceAttackAppsDirAsDefault(AppsFolder) then
begin
Result := RemoveBackslashUnlessRoot(AppsFolder);
exit;
end;
if TryGetLegacyVoiceAttackAppsDir(AppsFolder) and ShouldUseDetectedVoiceAttackAppsDirAsDefault(AppsFolder) then
begin
Result := RemoveBackslashUnlessRoot(AppsFolder);
exit;
end;
Result := GetPerUserVoiceAttackAppsDir;
end;
function GetSelectedVoiceAttackAppsDir: string;
begin
if Trim(SelectedVoiceAttackAppsDir) <> '' then
begin
Result := NormalizeVoiceAttackAppsDir(SelectedVoiceAttackAppsDir);
if (not IsAdminInstallMode) and (not IsUserProfilePath(Result)) then
Result := GetPerUserVoiceAttackAppsDir;
exit;
end;
Result := GetDefaultVoiceAttackAppsDir;
end;
function GetVoiceAttack2EddiDir(Param: string): string;
begin
Result := AddBackslash(GetSelectedVoiceAttackAppsDir) + '{#MyAppName}';
end;
function GetDefaultInstallDir(Param: string): string;
begin
if not IsAdminInstallMode then
begin
Result := ExpandConstant('{localappdata}\EDDI\Application');
exit;
end;
Result := ExpandConstant('{autopf}\EDDI');
end;
function GetDefaultApplicationInstallDir: string;
begin
Result := GetDefaultInstallDir('');
end;
procedure EnsureSelectedVoiceAttackAppsDirMatchesInstallMode;
begin
if (not IsAdminInstallMode) and
((Trim(SelectedVoiceAttackAppsDir) = '') or
(not IsUserProfilePath(NormalizeVoiceAttackAppsDir(SelectedVoiceAttackAppsDir)))) then
begin
SelectedVoiceAttackAppsDir := GetPerUserVoiceAttackAppsDir;
end;
end;
function ShouldWriteMachineLocator: Boolean;
begin
Result := IsAdminInstallMode and not IsUserProfilePath(ExpandConstant('{app}'));
end;
function ShouldWriteMachineRegistry: Boolean;
begin
Result := IsAdminInstallMode;
end;
function ShouldWriteCurrentUserRegistry: Boolean;
begin
Result := not IsAdminInstallMode;
end;
function ShouldModifyCurrentUserAreas: Boolean;
begin
Result := not IsAdminInstallMode;
end;
function GetPreviousEddiInstallDir: string;
begin
Result := '';
RegQueryStringValue(
HKLM,
'Software\Microsoft\Windows\CurrentVersion\Uninstall\{830C0324-30D8-423C-B5B4-D7EE8D007A79}_is1',
'InstallLocation',
Result);
if Trim(Result) <> '' then
Result := RemoveBackslashUnlessRoot(Result);
end;
function GetLegacyEddiDir: string;
var
LegacyAppsDir: string;
begin
Result := '';
if TryGetLegacyVoiceAttackAppsDir(LegacyAppsDir) then
Result := AddBackslash(RemoveBackslashUnlessRoot(LegacyAppsDir)) + '{#MyAppName}';
end;
function IsLegacyVoiceAttackPath(const Dir: string): Boolean;
var
LegacyAppsDir: string;
VoiceAttack2AppsDir: string;
begin
Result := False;
if not TryGetLegacyVoiceAttackAppsDir(LegacyAppsDir) then
exit;
{
VoiceAttack supports an in-place v1 -> v2 upgrade. In that case both
registry hives can legitimately point to the same Apps folder. Do not
block the selected path as legacy when the v1 and v2 Apps folders match.
}
if TryGetVoiceAttack2AppsDir(VoiceAttack2AppsDir) and
SamePath(LegacyAppsDir, VoiceAttack2AppsDir) then
begin
Log(Format(
'VoiceAttack and VoiceAttack 2 are registered to the same Apps folder: "%s".', [LegacyAppsDir]));
exit;
end;
Result := IsUnderPath(Dir, LegacyAppsDir);
end;
function IsVoiceAttack2Path(const Dir: string): Boolean;
var
VoiceAttack2AppsDir: string;
begin
Result := TryGetVoiceAttack2AppsDir(VoiceAttack2AppsDir) and
IsUnderPath(Dir, VoiceAttack2AppsDir);
end;
function IsAnyVoiceAttackAppsPath(const Dir: string): Boolean;
begin
Result := IsLegacyVoiceAttackPath(Dir) or IsVoiceAttack2Path(Dir);
end;
function IsKnownVoiceAttackAppsDir(const Dir: string): Boolean;
var
AppsDir: string;
begin
Result := False;
if TryGetVoiceAttack2AppsDir(AppsDir) and SamePath(Dir, AppsDir) then
begin
Result := True;
exit;
end;
if TryGetLegacyVoiceAttackAppsDir(AppsDir) and SamePath(Dir, AppsDir) then
begin
Result := True;
end;
end;
function LooksLikeVoiceAttackAppsDir(const Dir: string): Boolean;
begin
Result := Lowercase(ExtractFileName(NormalizeVoiceAttackAppsDir(Dir))) = 'apps';
end;
function ValidateVoiceAttackAppsDir(const AppsDir: string; ShowMessage: Boolean): Boolean;
begin
Result := True;
if Trim(AppsDir) = '' then
begin
if ShowMessage then
MsgBox('Select the VoiceAttack Apps folder where the EDDI plugin should be installed.', mbError, MB_OK);
Result := False;
exit;
end;
if not IsKnownVoiceAttackAppsDir(AppsDir) and not LooksLikeVoiceAttackAppsDir(AppsDir) then
begin
if ShowMessage then
MsgBox(
'Select the VoiceAttack Apps folder.' + #13#10#13#10 +
'The EDDI plugin will be installed under an EDDI subfolder inside of the selected Apps folder.',
mbError, MB_OK);
Result := False;
end;
end;
function SelectedLocationsRequireAdmin(const AppDir, AppsDir: string): Boolean;
begin
Result := (not IsUserProfilePath(AppDir)) or (not IsUserProfilePath(AppsDir));
end;
function ValidateInstallLocations(const AppDir, AppsDir: string; ShowMessage: Boolean): Boolean;
var
CleanAppDir: string;
CleanAppsDir: string;
ShimDir: string;
begin
Result := True;
CleanAppDir := RemoveBackslashUnlessRoot(AppDir);
CleanAppsDir := NormalizeVoiceAttackAppsDir(AppsDir);
ShimDir := AddBackslash(CleanAppsDir) + '{#MyAppName}';
if not ValidateVoiceAttackAppsDir(CleanAppsDir, ShowMessage) then
begin
Result := False;
exit;
end;
if IsAnyVoiceAttackAppsPath(CleanAppDir) or IsUnderPath(CleanAppDir, CleanAppsDir) then
begin
if ShowMessage then
MsgBox(
'The installer will install the EDDI VoiceAttack plugin separately.' + #13#10#13#10 +
'Please select a folder outside of the VoiceAttack Apps folder path.',
mbError, MB_OK);
Result := False;
exit;
end;
if IsUnderPath(CleanAppDir, ShimDir) or IsUnderPath(ShimDir, CleanAppDir) then
begin
if ShowMessage then
MsgBox(
'The installer will install the EDDI VoiceAttack plugin separately.' + #13#10#13#10 +
'Please select a folder outside the VoiceAttack Apps folder tree.',
mbError, MB_OK);
Result := False;
exit;
end;
if (not IsUserProfilePath(ShimDir)) and IsUserProfilePath(CleanAppDir) then
begin
if ShowMessage then
MsgBox(
'This install mixes a per-user EDDI application folder with a shared VoiceAttack Apps folder.' + #13#10#13#10 +
'For a single-user install, select your per-user VoiceAttack Apps folder:' + #13#10 +
ExpandConstant('{userappdata}\VoiceAttack2\Apps') + #13#10#13#10 +
'For a shared VoiceAttack Apps folder, restart Setup as administrator and install the EDDI application files to a shared folder such as Program Files.',
mbError, MB_OK);
Result := False;
exit;
end;
if IsAdminInstallMode and
(IsUserProfilePath(CleanAppDir) or IsUserProfilePath(CleanAppsDir)) then
begin
if ShowMessage then
MsgBox(
'The selected locations are per-user paths, but Setup is running in administrative install mode.' + #13#10#13#10 +
'Restart Setup without elevation or select shared machine-wide locations.',
mbError, MB_OK);
Result := False;
exit;
end;
if SelectedLocationsRequireAdmin(CleanAppDir, CleanAppsDir) and not IsAdminInstallMode then
begin
if ShowMessage then
MsgBox(
'The selected locations are shared or machine-wide and require administrative install mode.' + #13#10#13#10 +
'Restart Setup as administrator or select per-user locations.',
mbError, MB_OK);
Result := False;
end;
end;
function GetVoiceAttackShimDirForAppsDir(const AppsDir: string): string;
begin
Result := AddBackslash(NormalizeVoiceAttackAppsDir(AppsDir)) + '{#MyAppName}';
end;
procedure UpdateVoiceAttackPluginDirDisplay;
begin
if VoiceAttackPluginDirText <> nil then
VoiceAttackPluginDirText.Caption := GetVoiceAttackShimDirForAppsDir(VoiceAttackAppsDirEdit.Text);
end;
procedure VoiceAttackAppsDirEditChange(Sender: TObject);
begin
UpdateVoiceAttackPluginDirDisplay;
end;
procedure VoiceAttackAppsBrowseButtonClick(Sender: TObject);
var
Dir: string;
begin
Dir := VoiceAttackAppsDirEdit.Text;
if BrowseForFolder('Select your VoiceAttack Apps folder.', Dir, True) then
begin
VoiceAttackAppsDirEdit.Text := NormalizeVoiceAttackAppsDir(Dir);
UpdateVoiceAttackPluginDirDisplay;
end;
end;
procedure InitializeWizard;
var
LabelTop: Integer;
AppDirLabel: TNewStaticText;
AppsDirLabel: TNewStaticText;
PluginDirLabel: TNewStaticText;
begin
SelectedVoiceAttackAppsDir := GetDefaultVoiceAttackAppsDir;
EnsureSelectedVoiceAttackAppsDirMatchesInstallMode;
if not IsAdminInstallMode then
WizardForm.DirEdit.Text := GetDefaultApplicationInstallDir;
VoiceAttackAppsPage := CreateCustomPage(
wpSelectDir,
'VoiceAttack Plugin Location',
'Choose where EDDI installs its VoiceAttack plugin.');
LabelTop := 0;
AppDirLabel := TNewStaticText.Create(VoiceAttackAppsPage);
AppDirLabel.Parent := VoiceAttackAppsPage.Surface;
AppDirLabel.Left := 0;
AppDirLabel.Top := LabelTop;
AppDirLabel.Width := VoiceAttackAppsPage.SurfaceWidth;
AppDirLabel.Caption := 'EDDI application folder:';
ApplicationDirText := TNewStaticText.Create(VoiceAttackAppsPage);
ApplicationDirText.Parent := VoiceAttackAppsPage.Surface;
ApplicationDirText.Left := 0;
ApplicationDirText.Top := AppDirLabel.Top + AppDirLabel.Height + ScaleY(4);
ApplicationDirText.Width := VoiceAttackAppsPage.SurfaceWidth;
ApplicationDirText.Height := ScaleY(24);
ApplicationDirText.AutoSize := False;
AppsDirLabel := TNewStaticText.Create(VoiceAttackAppsPage);
AppsDirLabel.Parent := VoiceAttackAppsPage.Surface;
AppsDirLabel.Left := 0;
AppsDirLabel.Top := ApplicationDirText.Top + ApplicationDirText.Height + ScaleY(16);
AppsDirLabel.Width := VoiceAttackAppsPage.SurfaceWidth;
AppsDirLabel.Caption := 'VoiceAttack Apps folder:';
VoiceAttackAppsDirEdit := TNewEdit.Create(VoiceAttackAppsPage);
VoiceAttackAppsDirEdit.Parent := VoiceAttackAppsPage.Surface;
VoiceAttackAppsDirEdit.Left := 0;
VoiceAttackAppsDirEdit.Top := AppsDirLabel.Top + AppsDirLabel.Height + ScaleY(4);
VoiceAttackAppsDirEdit.Width := VoiceAttackAppsPage.SurfaceWidth - ScaleX(84);
VoiceAttackAppsDirEdit.Text := SelectedVoiceAttackAppsDir;
VoiceAttackAppsDirEdit.OnChange := @VoiceAttackAppsDirEditChange;
VoiceAttackAppsBrowseButton := TNewButton.Create(VoiceAttackAppsPage);
VoiceAttackAppsBrowseButton.Parent := VoiceAttackAppsPage.Surface;
VoiceAttackAppsBrowseButton.Left := VoiceAttackAppsDirEdit.Left + VoiceAttackAppsDirEdit.Width + ScaleX(8);
VoiceAttackAppsBrowseButton.Top := VoiceAttackAppsDirEdit.Top - ScaleY(1);
VoiceAttackAppsBrowseButton.Width := ScaleX(76);
VoiceAttackAppsBrowseButton.Height := VoiceAttackAppsDirEdit.Height + ScaleY(2);
VoiceAttackAppsBrowseButton.Caption := 'Browse...';
VoiceAttackAppsBrowseButton.OnClick := @VoiceAttackAppsBrowseButtonClick;
PluginDirLabel := TNewStaticText.Create(VoiceAttackAppsPage);
PluginDirLabel.Parent := VoiceAttackAppsPage.Surface;
PluginDirLabel.Left := 0;
PluginDirLabel.Top := VoiceAttackAppsDirEdit.Top + VoiceAttackAppsDirEdit.Height + ScaleY(16);
PluginDirLabel.Width := VoiceAttackAppsPage.SurfaceWidth;
PluginDirLabel.Caption := 'EDDI VoiceAttack plugin folder (for reference):';
VoiceAttackPluginDirText := TNewStaticText.Create(VoiceAttackAppsPage);
VoiceAttackPluginDirText.Parent := VoiceAttackAppsPage.Surface;
VoiceAttackPluginDirText.Left := 0;
VoiceAttackPluginDirText.Top := PluginDirLabel.Top + PluginDirLabel.Height + ScaleY(4);
VoiceAttackPluginDirText.Width := VoiceAttackAppsPage.SurfaceWidth;
VoiceAttackPluginDirText.Height := ScaleY(24);
VoiceAttackPluginDirText.AutoSize := False;
UpdateVoiceAttackPluginDirDisplay;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = VoiceAttackAppsPage.ID then
begin
EnsureSelectedVoiceAttackAppsDirMatchesInstallMode;
if not IsAdminInstallMode then
WizardForm.DirEdit.Text := GetDefaultApplicationInstallDir;
ApplicationDirText.Caption := RemoveBackslashUnlessRoot(WizardDirValue);
VoiceAttackAppsDirEdit.Text := GetSelectedVoiceAttackAppsDir;
UpdateVoiceAttackPluginDirDisplay;
end;
end;
function ShouldSkipPage(PageID: Integer): Boolean;
begin
Result := (PageID = wpSelectDir) and not IsAdminInstallMode;
end;
function AppendReadyMemoSection(
const ExistingMemo: string;
const Section: string;
const NewLine: string): string;
begin
Result := ExistingMemo;
if Trim(Section) = '' then
exit;
if Result <> '' then
Result := Result + NewLine + NewLine;
Result := Result + Section;
end;
function UpdateReadyMemo(
Space: string;
NewLine: string;
MemoUserInfoInfo: string;
MemoDirInfo: string;
MemoTypeInfo: string;
MemoComponentsInfo: string;
MemoGroupInfo: string;
MemoTasksInfo: string): string;
var
PluginDirInfo: string;
begin
EnsureSelectedVoiceAttackAppsDirMatchesInstallMode;
PluginDirInfo :=
Space + 'EDDI VoiceAttack plugin folder:' + NewLine +
Space + Space + GetVoiceAttack2EddiDir('');
Result := '';
Result := AppendReadyMemoSection(Result, MemoUserInfoInfo, NewLine);
Result := AppendReadyMemoSection(Result, MemoDirInfo, NewLine);
Result := AppendReadyMemoSection(Result, PluginDirInfo, NewLine);
Result := AppendReadyMemoSection(Result, MemoTypeInfo, NewLine);
Result := AppendReadyMemoSection(Result, MemoComponentsInfo, NewLine);
Result := AppendReadyMemoSection(Result, MemoGroupInfo, NewLine);
Result := AppendReadyMemoSection(Result, MemoTasksInfo, NewLine);
end;
function IsInAppUpgrade: Boolean;
begin
Result := ExpandConstant('{param:EDDIInAppUpgrade|0}') = '1';
end;
function ShouldRunAfterInAppUpgrade: Boolean;
begin
Result := IsInAppUpgrade or LegacySilentMigration;
end;
procedure RegisterCloseResource(const Dir: string);
var
ExePath: string;
begin
if Trim(Dir) = '' then
exit;
ExePath := AddBackslash(RemoveBackslashUnlessRoot(Dir)) + '{#MyAppExeName}';
if FileExists(ExePath) then
RegisterExtraCloseApplicationsResource(False, ExePath);
end;
procedure RegisterExtraCloseApplicationsResources;
begin
RegisterCloseResource(GetLegacyEddiDir);
RegisterCloseResource(GetPreviousEddiInstallDir);
end;
function RemoveDirIfOldEddiInstall(const Dir: string): Boolean;
var
CleanDir: string;
begin
Result := True;
if Trim(Dir) = '' then
exit;
CleanDir := RemoveBackslashUnlessRoot(Dir);
if not DirExists(CleanDir) then
exit;
if SamePath(CleanDir, ExpandConstant('{app}')) then
exit;
if FileExists(AddBackslash(CleanDir) + '{#MyAppExeName}') then
begin
Log(Format('Removing old EDDI install at "%s".', [CleanDir]));
Result := DelTree(CleanDir, True, True, True);
end;
end;
function RemoveOldEddiInstalls: Boolean;
begin
Result :=
RemoveDirIfOldEddiInstall(GetLegacyEddiDir) and
RemoveDirIfOldEddiInstall(GetPreviousEddiInstallDir);
end;
function RemoveOldVoiceAttackPluginDir(const ShimDir: string): Boolean;
var
CleanDir: string;
begin
Result := True;
if Trim(ShimDir) = '' then
exit;
CleanDir := RemoveBackslashUnlessRoot(ShimDir);
if not DirExists(CleanDir) then
exit;
if SamePath(CleanDir, ExpandConstant('{app}')) then
exit;
Log(Format('Removing old EDDI VoiceAttack plugin folder at "%s".', [CleanDir]));
Result := DelTree(CleanDir, True, True, True);
end;
function RemoveKnownVoiceAttackPluginDirs: Boolean;
var
AppsDir: string;
begin
Result := True;
if not RemoveOldVoiceAttackPluginDir(GetVoiceAttack2EddiDir('')) then
Result := False;
if TryGetVoiceAttack2AppsDir(AppsDir) then
begin
if not RemoveOldVoiceAttackPluginDir(GetVoiceAttackShimDirForAppsDir(AppsDir)) then
Result := False;
end;
if TryGetLegacyVoiceAttackAppsDir(AppsDir) then
begin
if not RemoveOldVoiceAttackPluginDir(GetVoiceAttackShimDirForAppsDir(AppsDir)) then
Result := False;
end;
if not RemoveOldVoiceAttackPluginDir(GetVoiceAttackShimDirForAppsDir(GetPerUserVoiceAttackAppsDir)) then
Result := False;
end;
procedure WriteVoiceAttackShimMarker;
var
ShimDir: string;
begin
ShimDir := GetVoiceAttack2EddiDir('');
ForceDirectories(ShimDir);
SaveStringToFile(
AddBackslash(RemoveBackslashUnlessRoot(ShimDir)) + 'eddi_app_path.txt',
ExpandConstant('{app}\{#MyAppExeName}'),
False);
end;
procedure DeleteShimFileIfExists(const FileName: string);
begin
if FileExists(FileName) then
begin
DeleteFile(FileName);
end;
end;
procedure RemoveVoiceAttackShimFiles;
var
ShimDir: string;
begin
ShimDir := AddBackslash(RemoveBackslashUnlessRoot(GetVoiceAttack2EddiDir('')));
DeleteShimFileIfExists(ShimDir + 'EddiVoiceAttackAdapter.dll');
DeleteShimFileIfExists(ShimDir + 'EddiVoiceAttackAdapter.pdb');
DeleteShimFileIfExists(ShimDir + 'EddiVoiceAttackAdapter.deps.json');
DeleteShimFileIfExists(ShimDir + 'EddiVoiceAttackAdapter.runtimeconfig.json');
DeleteShimFileIfExists(ShimDir + 'EDDI.vap');
DeleteShimFileIfExists(ShimDir + 'eddi_app_path.txt');
RemoveDir(ShimDir);
end;
procedure RemoveLocatorIfMatches(RootKey: Integer);
var
ExistingExecutablePath: string;
ExpectedExecutablePath: string;
begin
ExpectedExecutablePath := ExpandConstant('{app}\{#MyAppExeName}');
if RegQueryStringValue(
RootKey,
'Software\EDCD\EDDI',
'ExecutablePath',
ExistingExecutablePath) and
SamePath(ExistingExecutablePath, ExpectedExecutablePath) then
begin
RegDeleteValue(RootKey, 'Software\EDCD\EDDI', 'ExecutablePath');
RegDeleteValue(RootKey, 'Software\EDCD\EDDI', 'InstallDirectory');
RegDeleteValue(RootKey, 'Software\EDCD\EDDI', 'Version');
RegDeleteKeyIfEmpty(RootKey, 'Software\EDCD\EDDI');
RegDeleteKeyIfEmpty(RootKey, 'Software\EDCD');
end;
end;
function NextButtonClick(CurPageID: Integer): Boolean;
var
ChosenDir: string;
TargetDir: string;
begin
Result := True;
EnsureSelectedVoiceAttackAppsDirMatchesInstallMode;
if CurPageID = wpSelectDir then
begin
ChosenDir := RemoveBackslashUnlessRoot(WizardDirValue);
if not ValidateInstallLocations(ChosenDir, GetSelectedVoiceAttackAppsDir, False) then
begin
if WizardSilent then
begin
TargetDir := GetDefaultApplicationInstallDir;
Log(Format('Silent invalid application directory detected. Replacing selected application directory "%s" with "%s".', [ChosenDir, TargetDir]));
WizardForm.DirEdit.Text := TargetDir;
if IsAnyVoiceAttackAppsPath(ChosenDir) then
LegacySilentMigration := True;
Result := True;
exit;
end;
Result := ValidateInstallLocations(ChosenDir, GetSelectedVoiceAttackAppsDir, True);
exit;
end;
end;
if CurPageID = VoiceAttackAppsPage.ID then
begin
SelectedVoiceAttackAppsDir := NormalizeVoiceAttackAppsDir(VoiceAttackAppsDirEdit.Text);
VoiceAttackAppsDirEdit.Text := SelectedVoiceAttackAppsDir;
UpdateVoiceAttackPluginDirDisplay;
Result := ValidateInstallLocations(WizardDirValue, SelectedVoiceAttackAppsDir, True);
end;
end;
function PrepareToInstall(var NeedsRestart: Boolean): string;
var
AppDir: string;
AppsDir: string;
begin
Result := '';
EnsureSelectedVoiceAttackAppsDirMatchesInstallMode;
if not IsAdminInstallMode then
WizardForm.DirEdit.Text := GetDefaultApplicationInstallDir;
AppDir := RemoveBackslashUnlessRoot(WizardDirValue);
AppsDir := GetSelectedVoiceAttackAppsDir;
if not ValidateInstallLocations(AppDir, AppsDir, False) then
begin
Result :=
'The selected EDDI application and VoiceAttack plugin locations are not valid for this install mode. ' +
'Run Setup as administrator for shared machine-wide locations, or choose per-user locations.';
end;
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
RemovedOldEddiInstalls: Boolean;
RemovedVoiceAttackPlugins: Boolean;
begin
if CurStep = ssInstall then
begin
RemovedOldEddiInstalls := RemoveOldEddiInstalls;
RemovedVoiceAttackPlugins := RemoveKnownVoiceAttackPluginDirs;
if not (RemovedOldEddiInstalls and RemovedVoiceAttackPlugins) then
begin
MsgBox(
'Setup could not remove an old EDDI install or VoiceAttack plugin.' + #13#10#13#10 +
'Close EDDI and VoiceAttack, then run Setup again. If VoiceAttack is installed in Program Files, run Setup as administrator.',
mbCriticalError, MB_OK);
Abort;
end;
end;
if CurStep = ssPostInstall then
begin
WriteVoiceAttackShimMarker;
end;
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usUninstall then
begin
RemoveVoiceAttackShimFiles;
RemoveLocatorIfMatches(HKCU);
RemoveLocatorIfMatches(HKLM);
end;