-
Notifications
You must be signed in to change notification settings - Fork 5
/
devcppmingw64.nsi
507 lines (410 loc) · 15.5 KB
/
devcppmingw64.nsi
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
####################################################################
# Startup
!define COMPILERNAME "TDM-GCC 4.9.2"
!define COMPILERFOLDER "MinGW64"
!define DEVCPP_VERSION "5.11"
!define FINALNAME "Dev-Cpp ${DEVCPP_VERSION} ${COMPILERNAME} Setup.exe"
!define DISPLAY_NAME "Dev-C++ ${DEVCPP_VERSION}"
!include "MUI2.nsh"
####################################################################
# Installer Attributes
Name "${DISPLAY_NAME}"
OutFile "${FINALNAME}"
Caption "${DISPLAY_NAME}"
LicenseData "copying.txt"
InstallDir $PROGRAMFILES\Dev-Cpp
####################################################################
# Interface Settings
ShowInstDetails show
AutoCloseWindow false
SilentInstall normal
CRCCheck on
SetCompressor /SOLID /FINAL lzma
SetDatablockOptimize on
SetOverwrite try
XPStyle on
InstType "Full";1
InstType "Minimal";2
InstType "Safe";3
####################################################################
# Pages
!define MUI_ICON "devcpp.ico"
!define MUI_UNICON "devcpp.ico"
!define MUI_ABORTWARNING
!define MUI_LANGDLL_ALLLANGUAGES
!define MUI_FINISHPAGE_RUN "$INSTDIR\devcpp.exe"
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
!define MUI_COMPONENTSPAGE_SMALLDESC
!insertmacro MUI_PAGE_LICENSE "copying.txt"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
####################################################################
# Languages
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "Bulgarian"
!insertmacro MUI_LANGUAGE "Catalan"
!insertmacro MUI_LANGUAGE "Croatian"
!insertmacro MUI_LANGUAGE "Czech"
!insertmacro MUI_LANGUAGE "Danish"
!insertmacro MUI_LANGUAGE "Dutch"
!insertmacro MUI_LANGUAGE "Estonian"
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "Greek"
!insertmacro MUI_LANGUAGE "Hungarian"
!insertmacro MUI_LANGUAGE "Italian"
!insertmacro MUI_LANGUAGE "Korean"
!insertmacro MUI_LANGUAGE "Latvian"
!insertmacro MUI_LANGUAGE "Norwegian"
!insertmacro MUI_LANGUAGE "Polish"
!insertmacro MUI_LANGUAGE "Portuguese"
!insertmacro MUI_LANGUAGE "Romanian"
!insertmacro MUI_LANGUAGE "Russian"
!insertmacro MUI_LANGUAGE "Slovak"
!insertmacro MUI_LANGUAGE "Slovenian"
!insertmacro MUI_LANGUAGE "Spanish"
!insertmacro MUI_LANGUAGE "Swedish"
!insertmacro MUI_LANGUAGE "Turkish"
!insertmacro MUI_LANGUAGE "Ukrainian"
####################################################################
# Files, by option section
Section "Dev-C++ program files (required)" SectionMain
SectionIn 1 2 3 RO
SetOutPath $INSTDIR
; Allways create an uninstaller
WriteUninstaller "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Dev-C++" "DisplayName" "Dev-C++"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Dev-C++" "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Dev-C++" "DisplayVersion" "${DEVCPP_VERSION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Dev-C++" "DisplayIcon" "$INSTDIR\devcpp.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Dev-C++" "Publisher" "Bloodshed Software"
; Write required files
File "devcpp.exe"
File "devcppPortable.exe"
File "devcpp.map"
File "packman.exe"
File "Packman.map"
File "ConsolePauser.exe"
File "devcpp.exe.manifest"
File "copying.txt"
File "NEWS.txt"
; Write required paths
SetOutPath $INSTDIR\Lang
File /nonfatal /r "Lang\English.*"
SetOutPath $INSTDIR\Templates
File /nonfatal /r "Templates\*"
SetOutPath $INSTDIR\Help
File /nonfatal /r "Help\*"
SetOutPath $INSTDIR\AStyle
File /nonfatal /r "AStyle\*"
SectionEnd
Section "Icon files" SectionIcons
SectionIn 1 3
SetOutPath $INSTDIR\Icons
File /nonfatal /r "Icons\*.*"
SectionEnd
Section "${COMPILERNAME} compiler" SectionMinGW
SectionIn 1 2 3
SetOutPath $INSTDIR
File /nonfatal /r "${COMPILERFOLDER}"
SectionEnd
Section "Language files" SectionLangs
SectionIn 1 3
SetOutPath $INSTDIR\Lang
File /nonfatal /r "Lang\*"
SectionEnd
####################################################################
# File association
SubSection "Associate C and C++ files to Dev-C++" SectionAssocs
Section "Associate .dev files to Dev-C++"
SectionIn 1 3
StrCpy $0 ".dev"
Call BackupAssoc
StrCpy $0 $INSTDIR\DevCpp.exe
WriteRegStr HKCR ".dev" "" "DevCpp.dev"
WriteRegStr HKCR "DevCpp.dev" "" "Dev-C++ Project File"
WriteRegStr HKCR "DevCpp.dev\DefaultIcon" "" '$0,3'
WriteRegStr HKCR "DevCpp.dev\Shell\Open\Command" "" '$0 "%1"'
Call RefreshShellIcons
SectionEnd
Section "Associate .c files to Dev-C++"
SectionIn 1 3
StrCpy $0 ".c"
Call BackupAssoc
StrCpy $0 $INSTDIR\DevCpp.exe
WriteRegStr HKCR ".c" "" "DevCpp.c"
WriteRegStr HKCR "DevCpp.c" "" "C Source File"
WriteRegStr HKCR "DevCpp.c\DefaultIcon" "" '$0,4'
WriteRegStr HKCR "DevCpp.c\Shell\Open\Command" "" '$0 "%1"'
Call RefreshShellIcons
SectionEnd
Section "Associate .cpp files to Dev-C++"
SectionIn 1 3
StrCpy $0 ".cpp"
Call BackupAssoc
StrCpy $0 $INSTDIR\DevCpp.exe
WriteRegStr HKCR ".cpp" "" "DevCpp.cpp"
WriteRegStr HKCR "DevCpp.cpp" "" "C++ Source File"
WriteRegStr HKCR "DevCpp.cpp\DefaultIcon" "" '$0,5'
WriteRegStr HKCR "DevCpp.cpp\Shell\Open\Command" "" '$0 "%1"'
Call RefreshShellIcons
SectionEnd
Section "Associate .h files to Dev-C++"
SectionIn 1 3
StrCpy $0 ".h"
Call BackupAssoc
StrCpy $0 $INSTDIR\DevCpp.exe
WriteRegStr HKCR ".h" "" "DevCpp.h"
WriteRegStr HKCR "DevCpp.h" "" "C Header File"
WriteRegStr HKCR "DevCpp.h\DefaultIcon" "" '$0,6'
WriteRegStr HKCR "DevCpp.h\Shell\Open\Command" "" '$0 "%1"'
Call RefreshShellIcons
SectionEnd
Section "Associate .hpp files to Dev-C++"
SectionIn 1 3
StrCpy $0 ".hpp"
Call BackupAssoc
StrCpy $0 $INSTDIR\DevCpp.exe
WriteRegStr HKCR ".hpp" "" "DevCpp.hpp"
WriteRegStr HKCR "DevCpp.hpp" "" "C++ Header File"
WriteRegStr HKCR "DevCpp.hpp\DefaultIcon" "" '$0,7'
WriteRegStr HKCR "DevCpp.hpp\Shell\Open\Command" "" '$0 "%1"'
Call RefreshShellIcons
SectionEnd
Section "Associate .rc files to Dev-C++"
SectionIn 1 3
StrCpy $0 ".rc"
Call BackupAssoc
StrCpy $0 $INSTDIR\DevCpp.exe
WriteRegStr HKCR ".rc" "" "DevCpp.rc"
WriteRegStr HKCR "DevCpp.rc" "" "Resource Source File"
WriteRegStr HKCR "DevCpp.rc\DefaultIcon" "" '$0,8'
WriteRegStr HKCR "DevCpp.rc\Shell\Open\Command" "" '$0 "%1"'
Call RefreshShellIcons
SectionEnd
Section "Associate .devpak files to Dev-C++"
SectionIn 1 3
StrCpy $0 ".devpak"
Call BackupAssoc
StrCpy $0 $INSTDIR\DevCpp.exe
StrCpy $1 $INSTDIR\PackMan.exe
WriteRegStr HKCR ".devpak" "" "DevCpp.devpak"
WriteRegStr HKCR "DevCpp.devpak" "" "Dev-C++ Package File"
WriteRegStr HKCR "DevCpp.devpak\DefaultIcon" "" '$0,9'
WriteRegStr HKCR "DevCpp.devpak\Shell\Open\Command" "" '$1 "%1"'
Call RefreshShellIcons
SectionEnd
Section "Associate .devpackage files to Dev-C++"
SectionIn 1 3
StrCpy $0 ".devpackage"
Call BackupAssoc
StrCpy $0 $INSTDIR\DevCpp.exe
StrCpy $1 $INSTDIR\PackMan.exe
WriteRegStr HKCR ".devpackage" "" "DevCpp.devpackage"
WriteRegStr HKCR "DevCpp.devpackage" "" "Dev-C++ Package File"
WriteRegStr HKCR "DevCpp.devpackage\DefaultIcon" "" '$0,10'
WriteRegStr HKCR "DevCpp.devpackage\Shell\Open\Command" "" '$1 "%1"'
Call RefreshShellIcons
SectionEnd
Section "Associate .template files to Dev-C++"
SectionIn 1 3
StrCpy $0 ".template"
Call BackupAssoc
StrCpy $0 $INSTDIR\DevCpp.exe
WriteRegStr HKCR ".template" "" "DevCpp.template"
WriteRegStr HKCR "DevCpp.template" "" "Dev-C++ Template File"
WriteRegStr HKCR "DevCpp.template\DefaultIcon" "" '$0,1'
WriteRegStr HKCR "DevCpp.template\Shell\Open\Command" "" '$0 "%1"'
Call RefreshShellIcons
SectionEnd
SubSectionEnd
####################################################################
# Shortcuts
SubSection "Shortcuts" SectionShortcuts
Section "Create Start Menu shortcuts" SectionMenuLaunch
SectionIn 1 3
; always use all user start menu, normal users can delete these
SetShellVarContext all
StrCpy $0 $SMPROGRAMS ; start menu Programs folder
CreateDirectory "$0\Bloodshed Dev-C++"
CreateShortCut "$0\Bloodshed Dev-C++\Dev-C++.lnk" "$INSTDIR\devcpp.exe"
CreateShortCut "$0\Bloodshed Dev-C++\License.lnk" "$INSTDIR\copying.txt"
CreateShortCut "$0\Bloodshed Dev-C++\Uninstall Dev-C++.lnk" "$INSTDIR\uninstall.exe"
SectionEnd
Section "Create Desktop shortcut" SectionDesktopLaunch
SectionIn 1 3
; always use current user desktop, normal users can't delete all users' shortcuts
SetShellVarContext current
CreateShortCut "$DESKTOP\Dev-C++.lnk" "$INSTDIR\devcpp.exe"
SectionEnd
SubSectionEnd
Section "Remove old configuration files" SectionConfig
SectionIn 3
RMDir /r "$APPDATA\Dev-Cpp"
Delete "$INSTDIR\devcpp.ini"
Delete "$INSTDIR\devcpp.cfg"
Delete "$INSTDIR\cache.ccc"
Delete "$INSTDIR\defaultcode.cfg"
Delete "$INSTDIR\devshortcuts.cfg"
Delete "$INSTDIR\classfolders.dcf"
Delete "$INSTDIR\mirrors.cfg"
Delete "$INSTDIR\tools.ini"
Delete "$INSTDIR\devcpp.ci"
SectionEnd
####################################################################
# TODO: Create language tables that describe installation components using LangString
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SectionMain} "The Dev-C++ IDE (Integrated Development Environment), package manager and templates"
!insertmacro MUI_DESCRIPTION_TEXT ${SectionIcons} "Various icons that you can use in your programs"
#!insertmacro MUI_DESCRIPTION_TEXT ${SectionMinGW} "The ${COMPILERNAME} compiler and associated tools, headers and libraries"
!insertmacro MUI_DESCRIPTION_TEXT ${SectionLangs} "The Dev-C++ interface translated to different languages (other than English which is built-in)"
!insertmacro MUI_DESCRIPTION_TEXT ${SectionAssocs} "Use Dev-C++ as the default application for opening these types of files"
!insertmacro MUI_DESCRIPTION_TEXT ${SectionShortcuts} "Create shortcuts to Dev-C++ in various folders"
!insertmacro MUI_DESCRIPTION_TEXT ${SectionConfig} "Remove all leftover configuration files from previous installs"
!insertmacro MUI_FUNCTION_DESCRIPTION_END
####################################################################
# Functions, utilities
Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
IfFileExists "C:\Dev-Cpp\devcpp.exe" 0 +2
SectionSetFlags ${SectionConfig} ${SF_SELECTED} # Remove old Dev-Cpp config files
IfFileExists "$APPDATA\Dev-Cpp\devcpp.cfg" 0 +2 # deprecated config file
SectionSetFlags ${SectionConfig} ${SF_SELECTED}
FunctionEnd
;backup file association
Function BackupAssoc
;$0 is an extension - for example ".dev"
;check if backup already exists
ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Dev-C++\Backup" "$0"
;don't backup if backup exists in registry
StrCmp $1 "" 0 no_assoc
ReadRegStr $1 HKCR "$0" ""
;don't backup dev-cpp associations
StrCmp $1 "DevCpp$0" no_assoc
StrCmp $1 "" no_assoc
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Dev-C++\Backup" "$0" "$1"
no_assoc:
FunctionEnd
;restore file association
Function un.RestoreAssoc
;$0 is an extension - for example ".dev"
DeleteRegKey HKCR "$0"
ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Dev-C++\Backup" "$0"
StrCmp $1 "" no_backup
WriteRegStr HKCR "$0" "" "$1"
Call un.RefreshShellIcons
no_backup:
FunctionEnd
;http://nsis.sourceforge.net/archive/viewpage.php?pageid=202
;After changing file associations, you can call this macro to refresh the shell immediatly.
;It calls the shell32 function SHChangeNotify. This will force windows to reload your changes from the registry.
!define SHCNE_ASSOCCHANGED 0x08000000
!define SHCNF_IDLIST 0
Function RefreshShellIcons
; By jerome tremblay - april 2003
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v \
(${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
FunctionEnd
Function un.RefreshShellIcons
; By jerome tremblay - april 2003
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v \
(${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
FunctionEnd
Function un.DeleteDirIfEmpty
FindFirst $R0 $R1 "$0\*.*"
strcmp $R1 "." 0 NoDelete
FindNext $R0 $R1
strcmp $R1 ".." 0 NoDelete
ClearErrors
FindNext $R0 $R1
IfErrors 0 NoDelete
FindClose $R0
Sleep 1000
RMDir "$0"
NoDelete:
FindClose $R0
FunctionEnd
####################################################################
# uninstall
UninstallText "This program will uninstall Dev-C++, continue?"
ShowUninstDetails show
Section "Uninstall"
; Remove uninstaller
Delete "$INSTDIR\uninstall.exe"
; Remove start menu stuff, located in all users folder
SetShellVarContext all
Delete "$SMPROGRAMS\Bloodshed Dev-C++\Dev-C++.lnk"
Delete "$SMPROGRAMS\Bloodshed Dev-C++\License.lnk"
Delete "$SMPROGRAMS\Bloodshed Dev-C++\Uninstall Dev-C++.lnk"
RMDir "$SMPROGRAMS\Bloodshed Dev-C++"
; Remove desktop stuff, located in current user folder
SetShellVarContext current
Delete "$QUICKLAUNCH\Dev-C++.lnk"
Delete "$DESKTOP\Dev-C++.lnk"
; Restore file associations
StrCpy $0 ".dev"
Call un.RestoreAssoc
StrCpy $0 ".c"
Call un.RestoreAssoc
StrCpy $0 ".cpp"
Call un.RestoreAssoc
StrCpy $0 ".h"
Call un.RestoreAssoc
StrCpy $0 ".hpp"
Call un.RestoreAssoc
StrCpy $0 ".rc"
Call un.RestoreAssoc
StrCpy $0 ".devpak"
Call un.RestoreAssoc
StrCpy $0 ".devpackage"
Call un.RestoreAssoc
StrCpy $0 ".template"
Call un.RestoreAssoc
DeleteRegKey HKCR "DevCpp.dev"
DeleteRegKey HKCR "DevCpp.c"
DeleteRegKey HKCR "DevCpp.cpp"
DeleteRegKey HKCR "DevCpp.h"
DeleteRegKey HKCR "DevCpp.hpp"
DeleteRegKey HKCR "DevCpp.rc"
DeleteRegKey HKCR "DevCpp.devpak"
DeleteRegKey HKCR "DevCpp.devpackage"
DeleteRegKey HKCR "DevCpp.template"
Delete "$INSTDIR\Packman.map"
Delete "$INSTDIR\Packman.exe"
Delete "$INSTDIR\NEWS.txt"
Delete "$INSTDIR\devcpp.map"
Delete "$INSTDIR\devcpp.exe"
Delete "$INSTDIR\devcpp.exe.manifest"
Delete "$INSTDIR\devcppPortable.exe"
Delete "$INSTDIR\ConsolePauser.exe"
Delete "$INSTDIR\copying.txt"
RMDir /r "$INSTDIR\${COMPILERFOLDER}"
RMDir /r "$INSTDIR\Lang"
RMDir /r "$INSTDIR\Examples"
RMDir /r "$INSTDIR\Help"
RMDir /r "$INSTDIR\Icons"
RMDir /r "$INSTDIR\Packages"
RMDir /r "$INSTDIR\Templates"
RMDir /r "$INSTDIR\Astyle"
StrCpy $0 "$INSTDIR"
Call un.DeleteDirIfEmpty
; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Dev-C++"
IfSilent +2 ; Don't ask when running in silent mode
MessageBox MB_YESNO "Do you want to remove all the remaining configuration files?" IDNO Done
RMDir /r "$APPDATA\Dev-Cpp"
Delete "$INSTDIR\devcpp.ini"
Delete "$INSTDIR\devcpp.cfg"
Delete "$INSTDIR\cache.ccc"
Delete "$INSTDIR\defaultcode.cfg"
Delete "$INSTDIR\devshortcuts.cfg"
Delete "$INSTDIR\classfolders.dcf"
Delete "$INSTDIR\mirrors.cfg"
Delete "$INSTDIR\tools.ini"
Delete "$INSTDIR\devcpp.ci"
Done:
SectionEnd