-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathsetup_script.iss
More file actions
182 lines (160 loc) · 6.7 KB
/
setup_script.iss
File metadata and controls
182 lines (160 loc) · 6.7 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
#define VersionString "0.1.3"
#define AppId "1f7e9ebf-ed92-4d88-8eac-89e3fe53282c"
#define VC_Redist_URL "https://aka.ms/vs/17/release/vc_redist.x64.exe"
#define AppName "codepointer"
[Setup]
AppName={#AppName}
AppVersion={#VersionString}
AppId={#AppId}
DefaultDirName={localappdata}\Programs\{#AppName}
DefaultGroupName={#AppName}
UninstallDisplayIcon={app}\{#AppName}.ico
OutputDir=dist
;OutputBaseFilename={#AppName}-win64-v{#VersionString}
OutputBaseFilename={#AppName}-win64
Compression=lzma
SolidCompression=yes
ArchitecturesInstallIn64BitMode=x64
ShowComponentSizes=yes
SetupIconFile={#AppName}.ico
PrivilegesRequired=lowest
PrivilegesRequiredOverridesAllowed=dialog
[Files]
Source: "dist\windows-msvc\usr\bin\{#AppName}.exe"; DestDir: "{app}";
Source: "dist\windows-msvc\usr\bin\*.dll"; DestDir: "{app}";
Source: "dist\windows-msvc\usr\bin\generic\*.dll"; DestDir: "{app}\generic";
Source: "dist\windows-msvc\usr\bin\iconengines\*.dll"; DestDir: "{app}\iconengines";
Source: "dist\windows-msvc\usr\bin\imageformats\*.dll"; DestDir: "{app}\imageformats";
Source: "dist\windows-msvc\usr\bin\networkinformation\*.dll"; DestDir: "{app}\networkinformation";
Source: "dist\windows-msvc\usr\bin\platforms\*.dll"; DestDir: "{app}\platforms";
Source: "dist\windows-msvc\usr\bin\styles\*.dll"; DestDir: "{app}\styles";
Source: "dist\windows-msvc\usr\bin\tls\*.dll"; DestDir: "{app}\tls";
; Icons
;Source: "dist\windows-msvc\usr\share\icons\*"; DestDir: "{app}"; Flags: recursesubdirs ignoreversion noregerror allowunsafefiles
Source: "dist\windows-msvc\usr\share\icons\breeze\index.theme"; DestDir: "{app}\icons\breeze"; Flags: ignoreversion
Source: "dist\windows-msvc\usr\share\icons\breeze\actions\16\*.svg"; DestDir: "{app}\icons\breeze\actions\16\"; Flags: ignoreversion
Source: "dist\windows-msvc\usr\share\icons\breeze\actions\22\*.svg"; DestDir: "{app}\icons\breeze\actions\22\"; Flags: ignoreversion
Source: "dist\windows-msvc\usr\share\icons\breeze\actions\32\*.svg"; DestDir: "{app}\icons\breeze\actions\32\"; Flags: ignoreversion
Source: "dist\windows-msvc\usr\share\icons\breeze\devices\16\*.svg"; DestDir: "{app}\icons\breeze\devices\16\"; Flags: ignoreversion
Source: "dist\windows-msvc\usr\share\icons\breeze\devices\22\*.svg"; DestDir: "{app}\icons\breeze\devices\22\"; Flags: ignoreversion
Source: "dist\windows-msvc\usr\{#AppName}.ico"; DestDir: "{app}\"; Flags: ignoreversion
[Registry]
; Right-click menu for .txt (safe, does not steal default app)
Root: HKCU; Subkey: "Software\Classes\txtfile\shell\Edit with {#AppName}"; ValueType: string; ValueData: "Edit with {#AppName}"
Root: HKCU; Subkey: "Software\Classes\txtfile\shell\Edit with {#AppName}\command"; ValueType: string; ValueData: """{app}\{#AppName}.exe"" ""%1"""
; Optional: register custom file type
Root: HKCU; Subkey: "Software\Classes\{#AppName}.File"; ValueType: string; ValueData: "{#AppName} Document"
Root: HKCU; Subkey: "Software\Classes\{#AppName}.File\DefaultIcon"; ValueType: string; ValueData: "{app}\{#AppName}.exe,0"
Root: HKCU; Subkey: "Software\Classes\{#AppName}.File\shell\open\command"; ValueType: string; ValueData: """{app}\{#AppName}.exe"" ""%1"""
[UninstallDelete]
Type: filesandordirs; Name: "{app}\*"
[Icons]
Name: "{group}\{#AppName} v{#VersionString}"; Filename: "{app}\{#AppName}.exe"; Comment: "{#AppName} editor - version {#VersionString}"; Flags: uninsneveruninstall
[Code]
var
VCPage: TWizardPage;
BtnOpen: TNewButton;
BtnRecheck: TNewButton;
MsgLbl: TNewStaticText;
function IsVC2015_2022x64Installed: Boolean;
var
Val: Cardinal;
begin
Result := False;
if RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64',
'Installed', Val) and (Val = 1) then
Result := True
else if RegQueryDWordValue(HKLM, 'SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x64',
'Installed', Val) and (Val = 1) then
Result := True;
end;
procedure OpenVCRedistPage;
var
ErrorCode: Integer;
begin
ShellExec('', ExpandConstant('{#VC_Redist_URL}'), '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;
procedure BtnOpenClick(Sender: TObject);
begin
OpenVCRedistPage;
end;
procedure BtnRecheckClick(Sender: TObject);
begin
if IsVC2015_2022x64Installed then
MsgBox('Great! The Microsoft Visual C++ runtime is installed. Click Next to continue.', mbInformation, MB_OK)
else
MsgBox('Still not detected. Please finish installing the runtime, then click Re-check.', mbError, MB_OK);
end;
procedure InitializeWizard;
begin
if not IsVC2015_2022x64Installed then
begin
VCPage := CreateCustomPage(wpWelcome,
'Dependency Required',
'Microsoft Visual C++ 2015–2022 x64 Runtime not found');
MsgLbl := TNewStaticText.Create(VCPage);
MsgLbl.Parent := VCPage.Surface;
MsgLbl.Width := VCPage.SurfaceWidth;
MsgLbl.Top := ScaleY(8);
MsgLbl.WordWrap := True;
MsgLbl.Caption :=
'{#AppName} needs the Microsoft Visual C++ 2015–2022 x64 runtime.' + #13#10#13#10 +
'1) Click "Download" to get vc_redist.x64.exe from Microsoft.' + #13#10 +
'2) Install it, then return here and click "Re-check".';
BtnOpen := TNewButton.Create(VCPage);
BtnOpen.Parent := VCPage.Surface;
BtnOpen.Caption := 'Download';
BtnOpen.Left := 0;
BtnOpen.Top := MsgLbl.Top + MsgLbl.Height + ScaleY(12);
BtnOpen.OnClick := @BtnOpenClick;
BtnRecheck := TNewButton.Create(VCPage);
BtnRecheck.Parent := VCPage.Surface;
BtnRecheck.Caption := 'Re-check';
BtnRecheck.Left := BtnOpen.Left + BtnOpen.Width + ScaleX(8);
BtnRecheck.Top := BtnOpen.Top;
BtnRecheck.OnClick := @BtnRecheckClick;
end;
end;
function NextButtonClick(CurPageID: Integer): Boolean;
begin
Result := True;
if Assigned(VCPage) and (CurPageID = VCPage.ID) then
begin
if not IsVC2015_2022x64Installed then
begin
MsgBox('The Microsoft Visual C++ runtime is required. Please install it before continuing.',
mbError, MB_OK);
Result := False;
end;
end;
end;
procedure RemoveOldShortcuts;
var
OldShortcutPath: string;
FindRec: TFindRec;
CurrentShortcutName: string;
begin
OldShortcutPath := ExpandConstant('{group}\*');
CurrentShortcutName := '{#AppName} v{#VersionString}.lnk';
if FindFirst(OldShortcutPath, FindRec) then
begin
try
repeat
if (FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY = 0) and
(ExtractFileExt(FindRec.Name) = '.lnk') and
(CompareText(FindRec.Name, CurrentShortcutName) <> 0) then
begin
DeleteFile(ExpandConstant('{group}\' + FindRec.Name));
Log('Deleted old shortcut: ' + FindRec.Name);
end;
until not FindNext(FindRec);
finally
FindClose(FindRec);
end;
end;
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssInstall then
RemoveOldShortcuts;
end;