OSDN Git Service

0fb7120f49588742624c3979558f454f7876801e
[lamexp/LameXP.git] / etc / NSIS / setup.nsi
1 ; ///////////////////////////////////////////////////////////////////////////////
2 ; // LameXP - Audio Encoder Front-End
3 ; // Copyright (C) 2004-2023 LoRd_MuldeR <MuldeR2@GMX.de>
4 ; //
5 ; // This program is free software; you can redistribute it and/or modify
6 ; // it under the terms of the GNU GENERAL PUBLIC LICENSE as published by
7 ; // the Free Software Foundation; either version 2 of the License, or
8 ; // (at your option) any later version; always including the non-optional
9 ; // LAMEXP GNU GENERAL PUBLIC LICENSE ADDENDUM. See "License.txt" file!
10 ; //
11 ; // This program is distributed in the hope that it will be useful,
12 ; // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ; // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ; // GNU General Public License for more details.
15 ; //
16 ; // You should have received a copy of the GNU General Public License along
17 ; // with this program; if not, write to the Free Software Foundation, Inc.,
18 ; // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 ; //
20 ; // http://www.gnu.org/licenses/gpl-2.0.txt
21 ; ///////////////////////////////////////////////////////////////////////////////
22
23 ;--------------------------------
24 ;Basic Defines
25 ;--------------------------------
26
27 !ifndef NSIS_UNICODE
28   !error "NSIS_UNICODE is undefined, please compile with Unicode NSIS !!!"
29 !endif
30
31 !ifndef LAMEXP_VERSION
32   !error "LAMEXP_VERSION is not defined !!!"
33 !endif
34 !ifndef LAMEXP_BUILD
35   !error "LAMEXP_BUILD is not defined !!!"
36 !endif
37 !ifndef LAMEXP_INSTTYPE
38   !error "LAMEXP_INSTTYPE is not defined !!!"
39 !endif
40 !ifndef LAMEXP_PATCH
41   !error "LAMEXP_PATCH is not defined !!!"
42 !endif
43 !ifndef LAMEXP_DATE
44   !error "LAMEXP_DATE is not defined !!!"
45 !endif
46 !ifndef LAMEXP_OUTPUT_FILE
47   !error "LAMEXP_OUTPUT_FILE is not defined !!!"
48 !endif
49 !ifndef LAMEXP_SOURCE_PATH
50   !error "LAMEXP_SOURCE_PATH is not defined !!!"
51 !endif
52
53 ;UUID
54 !define MyRegPath "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{FBD7A67D-D700-4043-B54F-DD106D00F308}"
55
56 ;App Paths
57 !define AppPaths "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths"
58
59 ;Web-Site
60 !define MyWebSite "http://muldersoft.com/"
61
62 ;Prerequisites
63 !define PrerequisitesDir "..\..\..\Prerequisites"
64
65 ;--------------------------------
66 ;Check for Pre-Release
67 ;--------------------------------
68
69 !define LAMEXP_IS_PRERELEASE
70
71 !if '${LAMEXP_INSTTYPE}' == 'Final'
72   !undef LAMEXP_IS_PRERELEASE
73 !endif
74 !if '${LAMEXP_INSTTYPE}' == 'Hotfix'
75   !undef LAMEXP_IS_PRERELEASE
76 !endif
77
78
79 ;--------------------------------
80 ;Manifest
81 ;--------------------------------
82
83 !tempfile PACKHDRTEMP
84 !packhdr "${PACKHDRTEMP}" '"${PrerequisitesDir}\MSVC\redist\bin\mt.exe" -manifest "setup.manifest" -outputresource:"${PACKHDRTEMP};1" && "${PrerequisitesDir}\UPX\upx.exe" --brute "${PACKHDRTEMP}"'
85
86
87 ;--------------------------------
88 ;Includes
89 ;--------------------------------
90
91 !include `MUI2.nsh`
92 !include `WinVer.nsh`
93 !include `x64.nsh`
94 !include `StdUtils.nsh`
95
96
97 ;--------------------------------
98 ;Installer Attributes
99 ;--------------------------------
100
101 RequestExecutionLevel admin
102 ShowInstDetails show
103 ShowUninstDetails show
104 Name "LameXP v${LAMEXP_VERSION} ${LAMEXP_INSTTYPE}-${LAMEXP_PATCH} [Build #${LAMEXP_BUILD}]"
105 OutFile "${LAMEXP_OUTPUT_FILE}"
106 BrandingText "Date created: ${LAMEXP_DATE} [Build #${LAMEXP_BUILD}]"
107 InstallDir "$PROGRAMFILES\MuldeR\LameXP"
108 InstallDirRegKey HKLM "${MyRegPath}" "InstallLocation"
109
110
111 ;--------------------------------
112 ;Compressor
113 ;--------------------------------
114
115 SetCompressor /SOLID LZMA
116 SetCompressorDictSize 64
117
118
119 ;--------------------------------
120 ;Reserved Files
121 ;--------------------------------
122
123 ReserveFile "${NSISDIR}\Plugins\Aero.dll"
124 ReserveFile "${NSISDIR}\Plugins\LangDLL.dll"
125 ReserveFile "${NSISDIR}\Plugins\LockedList.dll"
126 ReserveFile "${NSISDIR}\Plugins\LockedList64.dll"
127 ReserveFile "${NSISDIR}\Plugins\nsDialogs.dll"
128 ReserveFile "${NSISDIR}\Plugins\nsExec.dll"
129 ReserveFile "${NSISDIR}\Plugins\StartMenu.dll"
130 ReserveFile "${NSISDIR}\Plugins\StdUtils.dll"
131 ReserveFile "${NSISDIR}\Plugins\System.dll"
132 ReserveFile "${NSISDIR}\Plugins\UserInfo.dll"
133
134
135 ;--------------------------------
136 ;Variables
137 ;--------------------------------
138
139 Var StartMenuFolder
140
141
142 ;--------------------------------
143 ;Version Info
144 ;--------------------------------
145
146 !searchreplace PRODUCT_VERSION_DATE "${LAMEXP_DATE}" "-" "."
147 VIProductVersion "${PRODUCT_VERSION_DATE}.${LAMEXP_BUILD}"
148
149 VIAddVersionKey "Author" "LoRd_MuldeR <mulder2@gmx.de>"
150 VIAddVersionKey "Comments" "This program is free software; you can redistribute it and/or modify it under the terms of the GNU GENERAL PUBLIC LICENSE as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version; always including the non-optional LAMEXP GNU GENERAL PUBLIC LICENSE ADDENDUM."
151 VIAddVersionKey "CompanyName" "Free Software Foundation"
152 VIAddVersionKey "FileDescription" "LameXP v${LAMEXP_VERSION} ${LAMEXP_INSTTYPE}-${LAMEXP_PATCH} [Build #${LAMEXP_BUILD}]"
153 VIAddVersionKey "FileVersion" "${PRODUCT_VERSION_DATE}.${LAMEXP_BUILD} (${LAMEXP_VERSION})"
154 VIAddVersionKey "LegalCopyright" "Copyright 2004-2023 LoRd_MuldeR"
155 VIAddVersionKey "LegalTrademarks" "GNU"
156 VIAddVersionKey "OriginalFilename" "LameXP.${LAMEXP_DATE}.exe"
157 VIAddVersionKey "ProductName" "LameXP - Audio Encoder Frontend"
158 VIAddVersionKey "ProductVersion" "${LAMEXP_VERSION}, Build #${LAMEXP_BUILD} (${LAMEXP_DATE})"
159 VIAddVersionKey "Website" "${MyWebSite}"
160
161
162 ;--------------------------------
163 ;MUI2 Interface Settings
164 ;--------------------------------
165
166 !define MUI_ABORTWARNING
167 !define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
168 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${MyRegPath}"
169 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "StartmenuFolder"
170 !define MUI_LANGDLL_REGISTRY_ROOT HKLM
171 !define MUI_LANGDLL_REGISTRY_KEY "${MyRegPath}"
172 !define MUI_LANGDLL_REGISTRY_VALUENAME "SetupLanguage"
173 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "LameXP v${LAMEXP_VERSION}"
174 !define MUI_FINISHPAGE_NOAUTOCLOSE
175 !define MUI_UNFINISHPAGE_NOAUTOCLOSE
176 !define MUI_FINISHPAGE_RUN
177 !define MUI_FINISHPAGE_RUN_FUNCTION RunAppFunction
178 !define MUI_FINISHPAGE_SHOWREADME
179 !define MUI_FINISHPAGE_SHOWREADME_FUNCTION ShowReadmeFunction
180 !define MUI_FINISHPAGE_LINK ${MyWebSite}
181 !define MUI_FINISHPAGE_LINK_LOCATION ${MyWebSite}
182 !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico"
183 !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall.ico"
184 !define MUI_WELCOMEFINISHPAGE_BITMAP "wizard.bmp"
185 !define MUI_UNWELCOMEFINISHPAGE_BITMAP "wizard-un.bmp"
186 !define MUI_HEADERIMAGE
187 !define MUI_HEADERIMAGE_BITMAP "header.bmp"
188 !define MUI_HEADERIMAGE_UNBITMAP "header-un.bmp"
189 !define MUI_LANGDLL_ALLLANGUAGES
190 !define MUI_CUSTOMFUNCTION_GUIINIT MyGuiInit
191 !define MUI_CUSTOMFUNCTION_UNGUIINIT un.MyGuiInit
192 !define MUI_LANGDLL_ALWAYSSHOW
193
194
195 ;--------------------------------
196 ;MUI2 Pages (Installer)
197 ;--------------------------------
198
199 ;Welcome
200 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
201 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE CheckForPreRelease
202 !define MUI_WELCOMEPAGE_TITLE_3LINES
203 !define MUI_FINISHPAGE_TITLE_3LINES
204 !insertmacro MUI_PAGE_WELCOME
205
206 ;License
207 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
208 !insertmacro MUI_PAGE_LICENSE "license.rtf"
209
210 ;Directory
211 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
212 !define MUI_PAGE_CUSTOMFUNCTION_SHOW CheckForUpdate
213 !insertmacro MUI_PAGE_DIRECTORY
214
215 ;Startmenu
216 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
217 !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
218
219 ;LockedList
220 Page Custom LockedListShow
221
222 ;Install Files
223 !insertmacro MUI_PAGE_INSTFILES
224
225 ;Finish
226 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
227 !insertmacro MUI_PAGE_FINISH
228
229
230 ;--------------------------------
231 ;MUI2 Pages (Uninstaller)
232 ;--------------------------------
233
234 ;Welcome
235 !define MUI_WELCOMEPAGE_TITLE_3LINES
236 !define MUI_FINISHPAGE_TITLE_3LINES
237 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.CheckForcedUninstall
238 !insertmacro MUI_UNPAGE_WELCOME
239
240 ;Confirm
241 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.CheckForcedUninstall
242 !insertmacro MUI_UNPAGE_CONFIRM
243
244 ;LockedList
245 UninstPage Custom un.LockedListShow
246
247 ;Uninstall
248 !insertmacro MUI_UNPAGE_INSTFILES
249
250 ;Finish
251 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.CheckForcedUninstall
252 !insertmacro MUI_UNPAGE_FINISH
253
254
255 ;--------------------------------
256 ;Languages
257 ;--------------------------------
258  
259 !insertmacro MUI_LANGUAGE "English" ;first language is the default language
260 !insertmacro MUI_LANGUAGE "Bulgarian"
261 !insertmacro MUI_LANGUAGE "German"
262 !insertmacro MUI_LANGUAGE "Hungarian"
263 !insertmacro MUI_LANGUAGE "Japanese"
264 !insertmacro MUI_LANGUAGE "Polish"
265 !insertmacro MUI_LANGUAGE "Russian"
266 !insertmacro MUI_LANGUAGE "Spanish"
267 !insertmacro MUI_LANGUAGE "Ukrainian"
268 !insertmacro MUI_LANGUAGE "Korean"
269
270 ; !insertmacro MUI_LANGUAGE "Afrikaans"
271 ; !insertmacro MUI_LANGUAGE "Arabic"
272 ; !insertmacro MUI_LANGUAGE "Dutch"
273 ; !insertmacro MUI_LANGUAGE "French"
274 ; !insertmacro MUI_LANGUAGE "Greek"
275 ; !insertmacro MUI_LANGUAGE "Indonesian"
276 ; !insertmacro MUI_LANGUAGE "Italian"
277 ; !insertmacro MUI_LANGUAGE "Malay"
278 ; !insertmacro MUI_LANGUAGE "Portuguese"
279 ; !insertmacro MUI_LANGUAGE "Romanian"
280 ; !insertmacro MUI_LANGUAGE "Serbian"
281 ; !insertmacro MUI_LANGUAGE "SerbianLatin"
282 ; !insertmacro MUI_LANGUAGE "SimpChinese"
283 ; !insertmacro MUI_LANGUAGE "SpanishInternational"
284 ; !insertmacro MUI_LANGUAGE "TradChinese"
285
286
287 ;--------------------------------
288 ;Translation
289 ;--------------------------------
290
291 ;English
292 !include "..\Translation\Blank.nsh" ;first language is the default language
293
294 ;Bulgarian
295 !include "..\Translation\LameXP_BG.nsh"
296
297 ;German
298 !include "..\Translation\LameXP_DE.nsh"
299
300 ;Hungarian
301 !include "..\Translation\LameXP_HU.nsh"
302
303 ;Japanese
304 !include "..\Translation\LameXP_JA.nsh"
305
306 ;Polish
307 !include "..\Translation\LameXP_PL.nsh"
308
309 ;Russian
310 !include "..\Translation\LameXP_RU.nsh"
311
312 ;Spanish
313 !include "..\Translation\LameXP_ES.nsh"
314
315 ;Ukrainian
316 !include "..\Translation\LameXP_UK.nsh"
317
318 ;Korean
319 !include "..\Translation\LameXP_KR.nsh"
320
321 ;--------------------------------
322 ;LogicLib Extensions
323 ;--------------------------------
324
325 !macro _UnattendedMode _a _b _t _f
326         !insertmacro _LOGICLIB_TEMP
327         ${StdUtils.TestParameter} $_LOGICLIB_TEMP "Update"
328         StrCmp "$_LOGICLIB_TEMP" "true" `${_t}` `${_f}`
329 !macroend
330 !define UnattendedMode `"" UnattendedMode ""`
331
332 !macro _ForcedMode _a _b _t _f
333         !insertmacro _LOGICLIB_TEMP
334         ${StdUtils.TestParameter} $_LOGICLIB_TEMP "Force"
335         StrCmp "$_LOGICLIB_TEMP" "true" `${_t}` `${_f}`
336 !macroend
337 !define ForcedMode `"" ForcedMode ""`
338
339 !macro _ValidFileName _a _b _t _f
340         !insertmacro _LOGICLIB_TEMP
341         ${StdUtils.ValidFileName} $_LOGICLIB_TEMP `${_b}`
342         StrCmp "$_LOGICLIB_TEMP" "ok" `${_t}` `${_f}`
343 !macroend
344 !define ValidFileName `"" ValidFileName`
345
346
347 ;--------------------------------
348 ;Installer initialization
349 ;--------------------------------
350
351 Function .onInit
352         InitPluginsDir
353
354         ; --------
355
356         System::Call 'kernel32::CreateMutexA(i 0, i 0, t "{2B3D1EBF-B3B6-4E93-92B9-6853029A7162}") i .r1 ?e'
357         Pop $0
358         ${If} $0 <> 0
359                 MessageBox MB_ICONSTOP|MB_TOPMOST "Sorry, the installer is already running!"
360                 Quit
361         ${EndIf}
362
363         ; --------
364         
365         # Running on Windows NT family?
366         ${IfNot} ${IsNT}
367                 MessageBox MB_TOPMOST|MB_ICONSTOP "Sorry, this application does *not* support Windows 9x/ME!"
368                 ExecShell "open" "http://windows.microsoft.com/"
369                 Quit
370         ${EndIf}
371
372         # Running on Windows XP or later?
373         ${If} ${AtMostWin2000}
374                 MessageBox MB_TOPMOST|MB_ICONSTOP "Sorry, but your operating system is *not* supported anymore.$\nInstallation will be aborted!$\n$\nThe minimum required platform is Windows XP (Service Pack 3)."
375                 ExecShell "open" "http://windows.microsoft.com/"
376                 Quit
377         ${EndIf}
378
379         # If on Windows XP, is the required Service Pack installed?
380         ${If} ${IsWinXP}
381                 ${IfNot} ${RunningX64} # Windows XP 32-Bit, requires Service Pack 3
382                 ${AndIf} ${AtMostServicePack} 2
383                         MessageBox MB_TOPMOST|MB_ICONEXCLAMATION "This application requires Service Pack 3 for Windows XP.$\nPlease install the required Service Pack and retry!"
384                         Quit
385                 ${EndIf}
386                 ${If} ${RunningX64} # Windows XP 64-Bit, requires Service Pack 2
387                 ${AndIf} ${AtMostServicePack} 1
388                         MessageBox MB_TOPMOST|MB_ICONEXCLAMATION "This application requires Service Pack 2 for Windows XP x64.$\nPlease install the required Service Pack and retry!"
389                         Quit
390                 ${EndIf}
391         ${EndIf}
392
393         # Running on Windows Vista?
394         ${If} ${IsWinVista}
395         ${AndIf} ${AtMostServicePack} 1
396                 MessageBox MB_TOPMOST|MB_ICONEXCLAMATION "This application requires Service Pack 2 for Windows Vista.$\nPlease install the required Service Pack and retry!"
397                 Quit
398         ${EndIf}
399
400         # Running on Windows 8.0?
401         ${If} ${IsWin8}
402                 ${WinVerGetBuild} $0
403                 ${If} $0 < 9600
404                         MessageBox MB_TOPMOST|MB_ICONEXCLAMATION "This application requires Windows 8.1 or later.$\nPlease upgrade your Windows and retry!"
405                         Quit
406                 ${EndIf}
407         ${EndIf}
408
409         ; --------
410
411         ${IfNot} ${UnattendedMode}
412                 !insertmacro MUI_LANGDLL_DISPLAY
413         ${EndIf}
414
415         ; --------
416
417         UserInfo::GetAccountType
418         Pop $0
419         ${If} $0 != "Admin"
420                 MessageBox MB_ICONSTOP|MB_TOPMOST "Your system requires administrative permissions in order to install this software."
421                 SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
422                 Quit
423         ${EndIf}
424 FunctionEnd
425
426 Function un.onInit
427         System::Call 'kernel32::CreateMutexA(i 0, i 0, t "{2B3D1EBF-B3B6-4E93-92B9-6853029A7162}") i .r1 ?e'
428         Pop $0
429         ${If} $0 <> 0
430                 MessageBox MB_ICONSTOP|MB_TOPMOST "Sorry, the un-installer is already running!"
431                 Quit
432         ${EndIf}
433
434         ${IfNot} ${ForcedMode}
435                 !insertmacro MUI_LANGDLL_DISPLAY
436         ${EndIf}
437         
438         ; --------
439
440         UserInfo::GetAccountType
441         Pop $0
442         ${If} $0 != "Admin"
443                 MessageBox MB_ICONSTOP|MB_TOPMOST "Your system requires administrative permissions in order to install this software."
444                 SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
445                 Quit
446         ${EndIf}
447 FunctionEnd
448
449
450 ;--------------------------------
451 ;GUI initialization
452 ;--------------------------------
453
454 Function MyGuiInit
455         StrCpy $0 $HWNDPARENT
456         System::Call "user32::SetWindowPos(i r0, i -1, i 0, i 0, i 0, i 0, i 3)"
457         Aero::Apply
458 FunctionEnd
459
460 Function un.MyGuiInit
461         StrCpy $0 $HWNDPARENT
462         System::Call "user32::SetWindowPos(i r0, i -1, i 0, i 0, i 0, i 0, i 3)"
463         Aero::Apply
464 FunctionEnd
465
466
467 ;--------------------------------
468 ;Macros & Auxiliary Functions
469 ;--------------------------------
470
471 !macro PrintProgress Text
472         SetDetailsPrint textonly
473         DetailPrint '${Text}'
474         SetDetailsPrint listonly
475         Sleep 1000
476 !macroend
477
478 !macro CreateWebLink ShortcutFile TargetURL
479         Push $0
480         Push $1
481         StrCpy $0 "${ShortcutFile}"
482         StrCpy $1 "${TargetURL}"
483         Call _CreateWebLink
484         Pop $1
485         Pop $0
486 !macroend
487
488 Function _CreateWebLink
489         FlushINI "$0"
490         SetFileAttributes "$0" FILE_ATTRIBUTE_NORMAL
491         DeleteINISec "$0" "DEFAULT"
492         DeleteINISec "$0" "InternetShortcut"
493         WriteINIStr "$0" "DEFAULT" "BASEURL" "$1"
494         WriteINIStr "$0" "InternetShortcut" "ORIGURL" "$1"
495         WriteINIStr "$0" "InternetShortcut" "URL" "$1"
496         WriteINIStr "$0" "InternetShortcut" "IconFile" "$SYSDIR\SHELL32.dll"
497         WriteINIStr "$0" "InternetShortcut" "IconIndex" "150"
498         FlushINI "$0"
499         SetFileAttributes "$0" FILE_ATTRIBUTE_READONLY
500 FunctionEnd
501
502 !macro GetExecutableName OutVar
503         ${StdUtils.GetParameter} ${OutVar} "Update" ""
504         ${StdUtils.TrimStr} ${OutVar}
505         ${If} "${OutVar}" == ""
506         ${OrIfNot} ${ValidFileName} "${OutVar}"
507                 StrCpy ${OutVar} "LameXP.exe"
508         ${EndIf}
509 !macroend
510
511 !macro DisableNextButton TmpVar
512         GetDlgItem ${TmpVar} $HWNDPARENT 1
513         EnableWindow ${TmpVar} 0
514 !macroend
515
516 !macro DisableBackButton TmpVar
517         GetDlgItem ${TmpVar} $HWNDPARENT 3
518         EnableWindow ${TmpVar} 0
519 !macroend
520
521 !macro CleanUpFiles options
522         Delete ${options} "$INSTDIR\Changelog.htm"
523         Delete ${options} "$INSTDIR\Changelog.html"
524         Delete ${options} "$INSTDIR\Contributors.txt"
525         Delete ${options} "$INSTDIR\Copying.txt"
526         Delete ${options} "$INSTDIR\FAQ.html"
527         Delete ${options} "$INSTDIR\Howto.html"
528         Delete ${options} "$INSTDIR\LameEnc.sys"
529         Delete ${options} "$INSTDIR\LameXP*.exe"
530         Delete ${options} "$INSTDIR\LameXP*.exe.sig"
531         Delete ${options} "$INSTDIR\LameXP*.rcc"
532         Delete ${options} "$INSTDIR\LameXP*.VisualElementsManifest.xml"
533         Delete ${options} "$INSTDIR\LameXP*.tag"
534         Delete ${options} "$INSTDIR\License.txt"
535         Delete ${options} "$INSTDIR\Manual.html"
536         Delete ${options} "$INSTDIR\Readme.htm"
537         Delete ${options} "$INSTDIR\Readme.html"
538         Delete ${options} "$INSTDIR\ReadMe.txt"
539         Delete ${options} "$INSTDIR\PRE_RELEASE_INFO.txt"
540         Delete ${options} "$INSTDIR\Settings.cfg"
541         Delete ${options} "$INSTDIR\Translate.html"
542         Delete ${options} "$INSTDIR\Uninstall.exe"
543         Delete ${options} "$INSTDIR\Qt*.dll"
544         Delete ${options} "$INSTDIR\MUtils*.dll"
545         Delete ${options} "$INSTDIR\msvcr*.dll"
546         Delete ${options} "$INSTDIR\msvcp*.dll"
547         Delete ${options} "$INSTDIR\concrt*.dll"
548         Delete ${options} "$INSTDIR\vcruntime*.dll"
549         Delete ${options} "$INSTDIR\vccorlib*.dll"
550         Delete ${options} "$INSTDIR\api-ms-*.dll"
551         Delete ${options} "$INSTDIR\ucrtbase.dll"
552         
553         RMDir /r ${options} "$INSTDIR\cache"
554         RMDir /r ${options} "$INSTDIR\img"
555         RMDir /r ${options} "$INSTDIR\imageformats"
556         RMDir /r ${options} "$INSTDIR\redist"
557 !macroend
558
559 !macro InstallRedist srcdir filename
560         File /a `/oname=$PLUGINSDIR\${filename}` `${srcdir}\${filename}`
561         ExecWait `"$PLUGINSDIR\${filename}" /passive`
562 !macroend
563
564 ;--------------------------------
565 ;Install Files
566 ;--------------------------------
567
568 Section "-PreInit"
569         SetShellVarContext all
570         SetOutPath "$INSTDIR"
571 SectionEnd
572
573 Section "-Clean Up Old Cruft"
574         !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_CLEANUP)"
575         !insertmacro CleanUpFiles ""
576 SectionEnd
577
578 Section "!Install Files"
579         !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_INSTFILES)"
580         
581         DeleteOldBinary:
582         !insertmacro GetExecutableName $R0
583         ClearErrors
584         Delete "$INSTDIR\$R0"
585         
586         ${If} ${Errors}
587                 MessageBox MB_TOPMOST|MB_ICONSTOP|MB_RETRYCANCEL 'Could not delete old "$R0" file. Is LameXP still running?' IDRETRY DeleteOldBinary
588                 Abort "Could not delete old binary!"
589         ${EndIf}
590         
591         File /a `/oname=$R0` `${LAMEXP_SOURCE_PATH}\LameXP.exe`
592         File /nonfatal /a /r `${LAMEXP_SOURCE_PATH}\*.dll`
593         File /nonfatal /a /r `${LAMEXP_SOURCE_PATH}\*.rcc`
594         
595         ${StdUtils.GetFileNamePart} $R1 "$R0"
596         File /a `/oname=$R1.VisualElementsManifest.xml` `${LAMEXP_SOURCE_PATH}\LameXP.VisualElementsManifest.xml`
597         File /a `/oname=$R1.tag` `${LAMEXP_SOURCE_PATH}\LameXP.tag`
598         
599         File /a /r `${LAMEXP_SOURCE_PATH}\*.txt`
600         File /a /r `${LAMEXP_SOURCE_PATH}\*.html`
601         File /a /r `${LAMEXP_SOURCE_PATH}\*.png`
602 SectionEnd
603
604 Section "-Write Uninstaller"
605         !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_MAKEUNINST)"
606         WriteUninstaller "$INSTDIR\Uninstall.exe"
607 SectionEnd
608
609 Section "-Install Runtime Libraries"
610         ${If} ${AtMostWinXP}
611         ${AndIfNot} ${FileExists} `$SYSDIR\normaliz.dll`
612                 !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_VCREDIST)"
613                 ${If} ${RunningX64}
614                         !insertmacro InstallRedist '${PrerequisitesDir}\IDNMInstaller' 'idndl.x64.exe'
615                 ${Else}
616                         !insertmacro InstallRedist '${PrerequisitesDir}\IDNMInstaller' 'idndl.x86.exe'
617                 ${EndIf}
618         ${EndIf}
619 SectionEnd
620
621 Section "-Create Shortcuts"
622         !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
623                 !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_SHORTCUTS)"
624                 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
625                 
626                 SetShellVarContext current
627                 
628                 Delete "$SMPROGRAMS\$StartMenuFolder\*.lnk"
629                 Delete "$SMPROGRAMS\$StartMenuFolder\*.pif"
630                 Delete "$SMPROGRAMS\$StartMenuFolder\*.url"
631                 
632                 SetShellVarContext all
633                 
634                 Delete "$SMPROGRAMS\$StartMenuFolder\*.lnk"
635                 Delete "$SMPROGRAMS\$StartMenuFolder\*.pif"
636                 Delete "$SMPROGRAMS\$StartMenuFolder\*.url"
637
638                 !insertmacro GetExecutableName $R0
639                 
640                 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk"                        "$INSTDIR\$R0" "" "$INSTDIR\$R0" 0
641                 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_LICENSE).lnk"   "$INSTDIR\License.txt"
642                 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_CHANGELOG).lnk" "$INSTDIR\Changelog.html"
643                 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_TRANSLATE).lnk" "$INSTDIR\Translate.html"
644                 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_MANUAL).lnk"    "$INSTDIR\Manual.html"
645                 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_UNINSTALL).lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0
646                 
647                 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Official LameXP Homepage.url" "${MyWebSite}"
648                 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Doom9's Forum.url"            "http://forum.doom9.org/"
649                 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Bug Tracker.url"              "https://github.com/lordmulder/LameXP/issues"
650                 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\RareWares.org.url"            "http://rarewares.org/"
651                 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Hydrogenaudio Forums.url"     "http://www.hydrogenaudio.org/"
652
653                 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk"
654                         ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "LameXP.lnk" ${StdUtils.Const.ShellVerb.PinToTaskbar}
655                         DetailPrint 'Pin: "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk" -> $R1'
656                 ${EndIf}
657         !insertmacro MUI_STARTMENU_WRITE_END
658 SectionEnd
659
660 Section "-Update Registry"
661         !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_REGISTRY)"
662
663         !insertmacro GetExecutableName $R0
664         WriteRegStr HKLM "${MyRegPath}" "InstallLocation" "$INSTDIR"
665         WriteRegStr HKLM "${MyRegPath}" "ExecutableName" "$R0"
666         WriteRegStr HKLM "${MyRegPath}" "DisplayIcon" "$INSTDIR\$R0,0"
667         WriteRegStr HKLM "${MyRegPath}" "UninstallString" '"$INSTDIR\Uninstall.exe"'
668         WriteRegStr HKLM "${MyRegPath}" "DisplayName" "LameXP v${LAMEXP_VERSION}"
669         WriteRegStr HKLM "${MyRegPath}" "Publisher" "LoRd_MuldeR <mulder2@gmx.de>"
670         WriteRegStr HKLM "${MyRegPath}" "DisplayVersion" "${LAMEXP_VERSION} ${LAMEXP_INSTTYPE}-${LAMEXP_PATCH} [Build #${LAMEXP_BUILD}]"
671         WriteRegStr HKLM "${MyRegPath}" "URLInfoAbout" "${MyWebSite}"
672         WriteRegStr HKLM "${MyRegPath}" "URLUpdateInfo" "${MyWebSite}"
673         
674         DeleteRegKey HKCU "${AppPaths}\LameXP.exe"
675         WriteRegStr HKLM "${AppPaths}\LameXP.exe" "" "$INSTDIR\$R0"
676         WriteRegStr HKLM "${AppPaths}\LameXP.exe" "Path" "$INSTDIR"
677 SectionEnd
678
679 Section "-Finished"
680         !insertmacro PrintProgress "$(MUI_TEXT_FINISH_TITLE)."
681
682 !ifdef LAMEXP_IS_PRERELEASE
683         ${If} ${FileExists} "$INSTDIR\PRE_RELEASE_INFO.txt"
684                 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\PRE_RELEASE_INFO.txt" "open" ""
685         ${EndIf}
686 !endif
687
688         ${IfThen} ${UnattendedMode} ${|} SetAutoClose true ${|}
689 SectionEnd
690
691
692 ;--------------------------------
693 ;Uninstaller
694 ;--------------------------------
695
696 Section "Uninstall"
697         SetOutPath "$EXEDIR"
698         !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_UNINSTALL)"
699
700         ; --------------
701         ; Startmenu
702         ; --------------
703         
704         !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
705         ${IfNot} "$StartMenuFolder" == ""
706                 SetShellVarContext current
707                 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk"
708                         ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "LameXP.lnk" ${StdUtils.Const.ShellVerb.UnpinFromTaskbar}
709                         DetailPrint 'Unpin: "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk" -> $R1'
710                 ${EndIf}
711                 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\*.*"
712                         Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.lnk"
713                         Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.url"
714                         RMDir "$SMPROGRAMS\$StartMenuFolder"
715                 ${EndIf}
716                 
717                 SetShellVarContext all
718                 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk"
719                         ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "LameXP.lnk" ${StdUtils.Const.ShellVerb.UnpinFromTaskbar}
720                         DetailPrint 'Unpin: "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk" -> $R1'
721                 ${EndIf}
722                 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\*.*"
723                         Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.lnk"
724                         Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.url"
725                         RMDir "$SMPROGRAMS\$StartMenuFolder"
726                 ${EndIf}
727         ${EndIf}
728
729         ; --------------
730         ; Files
731         ; --------------
732
733         ReadRegStr $R0 HKLM "${MyRegPath}" "ExecutableName"
734         ${IfThen} "$R0" == "" ${|} StrCpy $R0 "LameXP.exe" ${|}
735         ExecWait '"$INSTDIR\$R0" --uninstall'
736
737         Delete /REBOOTOK "$INSTDIR\$R0"
738         !insertmacro CleanUpFiles /REBOOTOK
739         RMDir "$INSTDIR"
740
741         ; --------------
742         ; Registry
743         ; --------------
744         
745         DeleteRegKey HKLM "${MyRegPath}"
746         DeleteRegKey HKCU "${MyRegPath}"
747
748         DeleteRegKey HKLM "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{54dcbccb-c905-46dc-b6e6-48563d0e9e55}"
749         DeleteRegKey HKCU "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{54dcbccb-c905-46dc-b6e6-48563d0e9e55}"
750         
751         DeleteRegKey HKLM "${AppPaths}\LameXP.exe"
752         DeleteRegKey HKCU "${AppPaths}\LameXP.exe"
753
754         MessageBox MB_YESNO|MB_TOPMOST "$(LAMEXP_LANG_UNINST_PERSONAL)" IDNO +3
755         Delete "$LOCALAPPDATA\LoRd_MuldeR\LameXP - Audio Encoder Front-End\config.ini"
756         Delete "$INSTDIR\*.ini"
757
758         !insertmacro PrintProgress "$(MUI_UNTEXT_FINISH_TITLE)."
759 SectionEnd
760
761
762 ;--------------------------------
763 ;Check For Update Mode
764 ;--------------------------------
765
766 Function SkipIfUnattended
767         ${IfThen} ${UnattendedMode} ${|} Abort ${|}
768 FunctionEnd
769
770 Function CheckForUpdate
771         ${If} "$INSTDIR" == ""
772         ${OrIf} "$INSTDIR" == "$EXEDIR"
773         ${OrIfNot} ${FileExists} "$INSTDIR\LameXP.exe"
774                 Return
775         ${EndIf}
776
777         FindWindow $R0 "#32770" "" $HWNDPARENT
778         GetDlgItem $R1 $R0 1019
779         EnableWindow $R1 0
780
781         FindWindow $R0 "#32770" "" $HWNDPARENT
782         GetDlgItem $R1 $R0 1001
783         EnableWindow $R1 0
784 FunctionEnd
785
786 Function un.CheckForcedUninstall
787         ${IfThen} ${ForcedMode} ${|} Abort ${|}
788 FunctionEnd
789
790
791 ;--------------------------------
792 ;Check For Pre-Release
793 ;--------------------------------
794
795 Function CheckForPreRelease
796         !ifdef LAMEXP_IS_PRERELEASE
797                 ${IfNot} ${UnattendedMode}
798                         MessageBox MB_TOPMOST|MB_ICONEXCLAMATION|MB_OKCANCEL "$(LAMEXP_LANG_PRERELEASE_WARNING)" /SD IDOK IDOK +2
799                         Quit
800                 ${EndIf}
801         !endif
802 FunctionEnd
803
804
805 ;--------------------------------
806 ;Locked List
807 ;--------------------------------
808
809 !macro _LockedListShow uinst
810         !insertmacro MUI_HEADER_TEXT "$(LAMEXP_LANG_LOCKEDLIST_HEADER)" "$(LAMEXP_LANG_LOCKEDLIST_TEXT)"
811         ${If} ${UnattendedMode}
812                 !insertmacro DisableBackButton $R0
813         ${EndIf}
814         ${If} ${RunningX64}
815                 InitPluginsDir
816                 File /oname=$PLUGINSDIR\LockedList64.dll `${NSISDIR}\Plugins\LockedList64.dll`
817         ${EndIf}
818         !insertmacro GetExecutableName $R0
819         LockedList::AddModule "\$R0"
820         ${If} "$R0" != "LameXP.exe"
821                 LockedList::AddModule "\LameXP.exe"
822         ${EndIf}
823         LockedList::AddModule "\Uninstall.exe"
824         !if ${uinst} < 1
825                 LockedList::AddModule "\Au_.exe"
826         !endif
827         #LockedList::AddFolder "$INSTDIR"
828         LockedList::Dialog /autonext /heading "$(LAMEXP_LANG_LOCKEDLIST_HEADING)" /noprograms "$(LAMEXP_LANG_LOCKEDLIST_NOPROG)" /searching  "$(LAMEXP_LANG_LOCKEDLIST_SEARCH)" /colheadings "$(LAMEXP_LANG_LOCKEDLIST_COLHDR1)" "$(LAMEXP_LANG_LOCKEDLIST_COLHDR2)"
829         Pop $R0
830 !macroend
831
832 Function LockedListShow
833         !insertmacro _LockedListShow 0
834 FunctionEnd
835
836 Function un.LockedListShow
837         !insertmacro _LockedListShow 1
838 FunctionEnd
839
840
841 ;--------------------------------
842 ;Install Success
843 ;--------------------------------
844
845 Function RunAppFunction
846         !insertmacro DisableNextButton $R0
847         !insertmacro GetExecutableName $R0
848         ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR" "explore" ""
849         ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\$R0" "open" "--first-run"
850 FunctionEnd
851
852 Function ShowReadmeFunction
853         !insertmacro DisableNextButton $R0
854         ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\Manual.html" "open" ""
855 FunctionEnd
856
857 Function .onInstSuccess
858         ${If} ${UnattendedMode}
859                 !insertmacro GetExecutableName $R0
860                 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\$R0" "open" "--first-run"
861         ${EndIf}
862 FunctionEnd