OSDN Git Service

fe1cfde2522097453ab9c45a4df501e7771ef963
[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
269 ; !insertmacro MUI_LANGUAGE "Afrikaans"
270 ; !insertmacro MUI_LANGUAGE "Arabic"
271 ; !insertmacro MUI_LANGUAGE "Dutch"
272 ; !insertmacro MUI_LANGUAGE "French"
273 ; !insertmacro MUI_LANGUAGE "Greek"
274 ; !insertmacro MUI_LANGUAGE "Indonesian"
275 ; !insertmacro MUI_LANGUAGE "Italian"
276 ; !insertmacro MUI_LANGUAGE "Malay"
277 ; !insertmacro MUI_LANGUAGE "Portuguese"
278 ; !insertmacro MUI_LANGUAGE "Romanian"
279 ; !insertmacro MUI_LANGUAGE "Serbian"
280 ; !insertmacro MUI_LANGUAGE "SerbianLatin"
281 ; !insertmacro MUI_LANGUAGE "SimpChinese"
282 ; !insertmacro MUI_LANGUAGE "SpanishInternational"
283 ; !insertmacro MUI_LANGUAGE "TradChinese"
284
285
286 ;--------------------------------
287 ;Translation
288 ;--------------------------------
289
290 ;English
291 !include "..\Translation\Blank.nsh" ;first language is the default language
292
293 ;Bulgarian
294 !include "..\Translation\LameXP_BG.nsh"
295
296 ;German
297 !include "..\Translation\LameXP_DE.nsh"
298
299 ;Hungarian
300 !include "..\Translation\LameXP_HU.nsh"
301
302 ;Japanese
303 !include "..\Translation\LameXP_JA.nsh"
304
305 ;Polish
306 !include "..\Translation\LameXP_PL.nsh"
307
308 ;Russian
309 !include "..\Translation\LameXP_RU.nsh"
310
311 ;Spanish
312 !include "..\Translation\LameXP_ES.nsh"
313
314 ;Ukrainian
315 !include "..\Translation\LameXP_UK.nsh"
316
317
318 ;--------------------------------
319 ;LogicLib Extensions
320 ;--------------------------------
321
322 !macro _UnattendedMode _a _b _t _f
323         !insertmacro _LOGICLIB_TEMP
324         ${StdUtils.TestParameter} $_LOGICLIB_TEMP "Update"
325         StrCmp "$_LOGICLIB_TEMP" "true" `${_t}` `${_f}`
326 !macroend
327 !define UnattendedMode `"" UnattendedMode ""`
328
329 !macro _ForcedMode _a _b _t _f
330         !insertmacro _LOGICLIB_TEMP
331         ${StdUtils.TestParameter} $_LOGICLIB_TEMP "Force"
332         StrCmp "$_LOGICLIB_TEMP" "true" `${_t}` `${_f}`
333 !macroend
334 !define ForcedMode `"" ForcedMode ""`
335
336 !macro _ValidFileName _a _b _t _f
337         !insertmacro _LOGICLIB_TEMP
338         ${StdUtils.ValidFileName} $_LOGICLIB_TEMP `${_b}`
339         StrCmp "$_LOGICLIB_TEMP" "ok" `${_t}` `${_f}`
340 !macroend
341 !define ValidFileName `"" ValidFileName`
342
343
344 ;--------------------------------
345 ;Installer initialization
346 ;--------------------------------
347
348 Function .onInit
349         InitPluginsDir
350
351         ; --------
352
353         System::Call 'kernel32::CreateMutexA(i 0, i 0, t "{2B3D1EBF-B3B6-4E93-92B9-6853029A7162}") i .r1 ?e'
354         Pop $0
355         ${If} $0 <> 0
356                 MessageBox MB_ICONSTOP|MB_TOPMOST "Sorry, the installer is already running!"
357                 Quit
358         ${EndIf}
359
360         ; --------
361         
362         # Running on Windows NT family?
363         ${IfNot} ${IsNT}
364                 MessageBox MB_TOPMOST|MB_ICONSTOP "Sorry, this application does *not* support Windows 9x/ME!"
365                 ExecShell "open" "http://windows.microsoft.com/"
366                 Quit
367         ${EndIf}
368
369         # Running on Windows XP or later?
370         ${If} ${AtMostWin2000}
371                 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)."
372                 ExecShell "open" "http://windows.microsoft.com/"
373                 Quit
374         ${EndIf}
375
376         # If on Windows XP, is the required Service Pack installed?
377         ${If} ${IsWinXP}
378                 ${IfNot} ${RunningX64} # Windows XP 32-Bit, requires Service Pack 3
379                 ${AndIf} ${AtMostServicePack} 2
380                         MessageBox MB_TOPMOST|MB_ICONEXCLAMATION "This application requires Service Pack 3 for Windows XP.$\nPlease install the required Service Pack and retry!"
381                         Quit
382                 ${EndIf}
383                 ${If} ${RunningX64} # Windows XP 64-Bit, requires Service Pack 2
384                 ${AndIf} ${AtMostServicePack} 1
385                         MessageBox MB_TOPMOST|MB_ICONEXCLAMATION "This application requires Service Pack 2 for Windows XP x64.$\nPlease install the required Service Pack and retry!"
386                         Quit
387                 ${EndIf}
388                 ${IfNot} ${UnattendedMode}
389                         ${If} ${Cmd} `MessageBox MB_TOPMOST|MB_ICONEXCLAMATION|MB_OKCANCEL|MB_DEFBUTTON2 "It appears that you are still running Windows XP, which reached $\"end of life$\" in April 2014 and therefore will not receive any updates or bug fixes anymore - not even for critical security vulnerabilities! We highly recommend updating to a contemporary operating system.$\n$\nClick 'OK' to proceed with the installation, or click 'Cancel' to abort." IDCANCEL`
390                                 Quit
391                         ${EndIf}
392                 ${EndIf}
393         ${EndIf}
394
395         # Running on Windows Vista?
396         ${If} ${IsWinVista}
397                 ${If} ${AtMostServicePack} 1
398                         MessageBox MB_TOPMOST|MB_ICONEXCLAMATION "This application requires Service Pack 2 for Windows Vista.$\nPlease install the required Service Pack and retry!"
399                         Quit
400                 ${EndIf}
401                 ${IfNot} ${UnattendedMode}
402                         ${If} ${Cmd} `MessageBox MB_TOPMOST|MB_ICONEXCLAMATION|MB_OKCANCEL|MB_DEFBUTTON2 "It appears that you are still running Windows Vista, which reached $\"end of life$\" in April 2017 and therefore will not receive any updates or bug fixes anymore - not even for critical security vulnerabilities! We highly recommend updating to a contemporary operating system.$\n$\nClick 'OK' to proceed with the installation, or click 'Cancel' to abort." IDCANCEL`
403                                 Quit
404                         ${EndIf}
405                 ${EndIf}
406         ${EndIf}
407
408         ; --------
409
410         ${IfNot} ${UnattendedMode}
411                 !insertmacro MUI_LANGDLL_DISPLAY
412         ${EndIf}
413
414         ; --------
415
416         UserInfo::GetAccountType
417         Pop $0
418         ${If} $0 != "Admin"
419                 MessageBox MB_ICONSTOP|MB_TOPMOST "Your system requires administrative permissions in order to install this software."
420                 SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
421                 Quit
422         ${EndIf}
423 FunctionEnd
424
425 Function un.onInit
426         System::Call 'kernel32::CreateMutexA(i 0, i 0, t "{2B3D1EBF-B3B6-4E93-92B9-6853029A7162}") i .r1 ?e'
427         Pop $0
428         ${If} $0 <> 0
429                 MessageBox MB_ICONSTOP|MB_TOPMOST "Sorry, the un-installer is already running!"
430                 Quit
431         ${EndIf}
432
433         ${IfNot} ${ForcedMode}
434                 !insertmacro MUI_LANGDLL_DISPLAY
435         ${EndIf}
436         
437         ; --------
438
439         UserInfo::GetAccountType
440         Pop $0
441         ${If} $0 != "Admin"
442                 MessageBox MB_ICONSTOP|MB_TOPMOST "Your system requires administrative permissions in order to install this software."
443                 SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
444                 Quit
445         ${EndIf}
446 FunctionEnd
447
448
449 ;--------------------------------
450 ;GUI initialization
451 ;--------------------------------
452
453 Function MyGuiInit
454         StrCpy $0 $HWNDPARENT
455         System::Call "user32::SetWindowPos(i r0, i -1, i 0, i 0, i 0, i 0, i 3)"
456         Aero::Apply
457 FunctionEnd
458
459 Function un.MyGuiInit
460         StrCpy $0 $HWNDPARENT
461         System::Call "user32::SetWindowPos(i r0, i -1, i 0, i 0, i 0, i 0, i 3)"
462         Aero::Apply
463 FunctionEnd
464
465
466 ;--------------------------------
467 ;Macros & Auxiliary Functions
468 ;--------------------------------
469
470 !macro PrintProgress Text
471         SetDetailsPrint textonly
472         DetailPrint '${Text}'
473         SetDetailsPrint listonly
474         Sleep 1000
475 !macroend
476
477 !macro CreateWebLink ShortcutFile TargetURL
478         Push $0
479         Push $1
480         StrCpy $0 "${ShortcutFile}"
481         StrCpy $1 "${TargetURL}"
482         Call _CreateWebLink
483         Pop $1
484         Pop $0
485 !macroend
486
487 Function _CreateWebLink
488         FlushINI "$0"
489         SetFileAttributes "$0" FILE_ATTRIBUTE_NORMAL
490         DeleteINISec "$0" "DEFAULT"
491         DeleteINISec "$0" "InternetShortcut"
492         WriteINIStr "$0" "DEFAULT" "BASEURL" "$1"
493         WriteINIStr "$0" "InternetShortcut" "ORIGURL" "$1"
494         WriteINIStr "$0" "InternetShortcut" "URL" "$1"
495         WriteINIStr "$0" "InternetShortcut" "IconFile" "$SYSDIR\SHELL32.dll"
496         WriteINIStr "$0" "InternetShortcut" "IconIndex" "150"
497         FlushINI "$0"
498         SetFileAttributes "$0" FILE_ATTRIBUTE_READONLY
499 FunctionEnd
500
501 !macro GetExecutableName OutVar
502         ${StdUtils.GetParameter} ${OutVar} "Update" ""
503         ${StdUtils.TrimStr} ${OutVar}
504         ${If} "${OutVar}" == ""
505         ${OrIfNot} ${ValidFileName} "${OutVar}"
506                 StrCpy ${OutVar} "LameXP.exe"
507         ${EndIf}
508 !macroend
509
510 !macro DisableNextButton TmpVar
511         GetDlgItem ${TmpVar} $HWNDPARENT 1
512         EnableWindow ${TmpVar} 0
513 !macroend
514
515 !macro DisableBackButton TmpVar
516         GetDlgItem ${TmpVar} $HWNDPARENT 3
517         EnableWindow ${TmpVar} 0
518 !macroend
519
520 !macro CleanUpFiles options
521         Delete ${options} "$INSTDIR\Changelog.htm"
522         Delete ${options} "$INSTDIR\Changelog.html"
523         Delete ${options} "$INSTDIR\Contributors.txt"
524         Delete ${options} "$INSTDIR\Copying.txt"
525         Delete ${options} "$INSTDIR\FAQ.html"
526         Delete ${options} "$INSTDIR\Howto.html"
527         Delete ${options} "$INSTDIR\LameEnc.sys"
528         Delete ${options} "$INSTDIR\LameXP*.exe"
529         Delete ${options} "$INSTDIR\LameXP*.exe.sig"
530         Delete ${options} "$INSTDIR\LameXP*.rcc"
531         Delete ${options} "$INSTDIR\LameXP*.VisualElementsManifest.xml"
532         Delete ${options} "$INSTDIR\LameXP*.tag"
533         Delete ${options} "$INSTDIR\License.txt"
534         Delete ${options} "$INSTDIR\Manual.html"
535         Delete ${options} "$INSTDIR\Readme.htm"
536         Delete ${options} "$INSTDIR\Readme.html"
537         Delete ${options} "$INSTDIR\ReadMe.txt"
538         Delete ${options} "$INSTDIR\PRE_RELEASE_INFO.txt"
539         Delete ${options} "$INSTDIR\Settings.cfg"
540         Delete ${options} "$INSTDIR\Translate.html"
541         Delete ${options} "$INSTDIR\Uninstall.exe"
542         Delete ${options} "$INSTDIR\Qt*.dll"
543         Delete ${options} "$INSTDIR\MUtils*.dll"
544         Delete ${options} "$INSTDIR\msvcr*.dll"
545         Delete ${options} "$INSTDIR\msvcp*.dll"
546         Delete ${options} "$INSTDIR\concrt*.dll"
547         Delete ${options} "$INSTDIR\vcruntime*.dll"
548         Delete ${options} "$INSTDIR\vccorlib*.dll"
549         Delete ${options} "$INSTDIR\api-ms-*.dll"
550         Delete ${options} "$INSTDIR\ucrtbase.dll"
551         
552         RMDir /r ${options} "$INSTDIR\cache"
553         RMDir /r ${options} "$INSTDIR\img"
554         RMDir /r ${options} "$INSTDIR\imageformats"
555         RMDir /r ${options} "$INSTDIR\redist"
556 !macroend
557
558 !macro InstallRedist srcdir filename
559         File /a `/oname=$PLUGINSDIR\${filename}` `${srcdir}\${filename}`
560         ExecWait `"$PLUGINSDIR\${filename}" /passive`
561 !macroend
562
563 ;--------------------------------
564 ;Install Files
565 ;--------------------------------
566
567 Section "-PreInit"
568         SetShellVarContext all
569         SetOutPath "$INSTDIR"
570 SectionEnd
571
572 Section "-Clean Up Old Cruft"
573         !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_CLEANUP)"
574         !insertmacro CleanUpFiles ""
575 SectionEnd
576
577 Section "!Install Files"
578         !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_INSTFILES)"
579         
580         DeleteOldBinary:
581         !insertmacro GetExecutableName $R0
582         ClearErrors
583         Delete "$INSTDIR\$R0"
584         
585         ${If} ${Errors}
586                 MessageBox MB_TOPMOST|MB_ICONSTOP|MB_RETRYCANCEL 'Could not delete old "$R0" file. Is LameXP still running?' IDRETRY DeleteOldBinary
587                 Abort "Could not delete old binary!"
588         ${EndIf}
589         
590         File /a `/oname=$R0` `${LAMEXP_SOURCE_PATH}\LameXP.exe`
591         File /nonfatal /a /r `${LAMEXP_SOURCE_PATH}\*.dll`
592         File /nonfatal /a /r `${LAMEXP_SOURCE_PATH}\*.rcc`
593         
594         ${StdUtils.GetFileNamePart} $R1 "$R0"
595         File /a `/oname=$R1.VisualElementsManifest.xml` `${LAMEXP_SOURCE_PATH}\LameXP.VisualElementsManifest.xml`
596         File /a `/oname=$R1.tag` `${LAMEXP_SOURCE_PATH}\LameXP.tag`
597         
598         File /a /r `${LAMEXP_SOURCE_PATH}\*.txt`
599         File /a /r `${LAMEXP_SOURCE_PATH}\*.html`
600         File /a /r `${LAMEXP_SOURCE_PATH}\*.png`
601 SectionEnd
602
603 Section "-Write Uninstaller"
604         !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_MAKEUNINST)"
605         WriteUninstaller "$INSTDIR\Uninstall.exe"
606 SectionEnd
607
608 Section "-Install Runtime Libraries"
609         ${If} ${AtMostWinXP}
610         ${AndIfNot} ${FileExists} `$SYSDIR\normaliz.dll`
611                 !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_VCREDIST)"
612                 ${If} ${RunningX64}
613                         !insertmacro InstallRedist '${PrerequisitesDir}\IDNMInstaller' 'idndl.x64.exe'
614                 ${Else}
615                         !insertmacro InstallRedist '${PrerequisitesDir}\IDNMInstaller' 'idndl.x86.exe'
616                 ${EndIf}
617         ${EndIf}
618 SectionEnd
619
620 Section "-Create Shortcuts"
621         !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
622                 !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_SHORTCUTS)"
623                 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
624                 
625                 SetShellVarContext current
626                 
627                 Delete "$SMPROGRAMS\$StartMenuFolder\*.lnk"
628                 Delete "$SMPROGRAMS\$StartMenuFolder\*.pif"
629                 Delete "$SMPROGRAMS\$StartMenuFolder\*.url"
630                 
631                 SetShellVarContext all
632                 
633                 Delete "$SMPROGRAMS\$StartMenuFolder\*.lnk"
634                 Delete "$SMPROGRAMS\$StartMenuFolder\*.pif"
635                 Delete "$SMPROGRAMS\$StartMenuFolder\*.url"
636
637                 !insertmacro GetExecutableName $R0
638                 
639                 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk"                        "$INSTDIR\$R0" "" "$INSTDIR\$R0" 0
640                 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_LICENSE).lnk"   "$INSTDIR\License.txt"
641                 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_CHANGELOG).lnk" "$INSTDIR\Changelog.html"
642                 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_TRANSLATE).lnk" "$INSTDIR\Translate.html"
643                 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_MANUAL).lnk"    "$INSTDIR\Manual.html"
644                 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_UNINSTALL).lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0
645                 
646                 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Official LameXP Homepage.url" "${MyWebSite}"
647                 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Doom9's Forum.url"            "http://forum.doom9.org/"
648                 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Bug Tracker.url"              "https://github.com/lordmulder/LameXP/issues"
649                 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\RareWares.org.url"            "http://rarewares.org/"
650                 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Hydrogenaudio Forums.url"     "http://www.hydrogenaudio.org/"
651
652                 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk"
653                         ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "LameXP.lnk" ${StdUtils.Const.ShellVerb.PinToTaskbar}
654                         DetailPrint 'Pin: "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk" -> $R1'
655                 ${EndIf}
656         !insertmacro MUI_STARTMENU_WRITE_END
657 SectionEnd
658
659 Section "-Update Registry"
660         !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_REGISTRY)"
661
662         !insertmacro GetExecutableName $R0
663         WriteRegStr HKLM "${MyRegPath}" "InstallLocation" "$INSTDIR"
664         WriteRegStr HKLM "${MyRegPath}" "ExecutableName" "$R0"
665         WriteRegStr HKLM "${MyRegPath}" "DisplayIcon" "$INSTDIR\$R0,0"
666         WriteRegStr HKLM "${MyRegPath}" "UninstallString" '"$INSTDIR\Uninstall.exe"'
667         WriteRegStr HKLM "${MyRegPath}" "DisplayName" "LameXP v${LAMEXP_VERSION}"
668         WriteRegStr HKLM "${MyRegPath}" "Publisher" "LoRd_MuldeR <mulder2@gmx.de>"
669         WriteRegStr HKLM "${MyRegPath}" "DisplayVersion" "${LAMEXP_VERSION} ${LAMEXP_INSTTYPE}-${LAMEXP_PATCH} [Build #${LAMEXP_BUILD}]"
670         WriteRegStr HKLM "${MyRegPath}" "URLInfoAbout" "${MyWebSite}"
671         WriteRegStr HKLM "${MyRegPath}" "URLUpdateInfo" "${MyWebSite}"
672         
673         DeleteRegKey HKCU "${AppPaths}\LameXP.exe"
674         WriteRegStr HKLM "${AppPaths}\LameXP.exe" "" "$INSTDIR\$R0"
675         WriteRegStr HKLM "${AppPaths}\LameXP.exe" "Path" "$INSTDIR"
676 SectionEnd
677
678 Section "-Finished"
679         !insertmacro PrintProgress "$(MUI_TEXT_FINISH_TITLE)."
680
681 !ifdef LAMEXP_IS_PRERELEASE
682         ${If} ${FileExists} "$INSTDIR\PRE_RELEASE_INFO.txt"
683                 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\PRE_RELEASE_INFO.txt" "open" ""
684         ${EndIf}
685 !endif
686
687         ${IfThen} ${UnattendedMode} ${|} SetAutoClose true ${|}
688 SectionEnd
689
690
691 ;--------------------------------
692 ;Uninstaller
693 ;--------------------------------
694
695 Section "Uninstall"
696         SetOutPath "$EXEDIR"
697         !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_UNINSTALL)"
698
699         ; --------------
700         ; Startmenu
701         ; --------------
702         
703         !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
704         ${IfNot} "$StartMenuFolder" == ""
705                 SetShellVarContext current
706                 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk"
707                         ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "LameXP.lnk" ${StdUtils.Const.ShellVerb.UnpinFromTaskbar}
708                         DetailPrint 'Unpin: "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk" -> $R1'
709                 ${EndIf}
710                 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\*.*"
711                         Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.lnk"
712                         Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.url"
713                         RMDir "$SMPROGRAMS\$StartMenuFolder"
714                 ${EndIf}
715                 
716                 SetShellVarContext all
717                 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk"
718                         ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "LameXP.lnk" ${StdUtils.Const.ShellVerb.UnpinFromTaskbar}
719                         DetailPrint 'Unpin: "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk" -> $R1'
720                 ${EndIf}
721                 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\*.*"
722                         Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.lnk"
723                         Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.url"
724                         RMDir "$SMPROGRAMS\$StartMenuFolder"
725                 ${EndIf}
726         ${EndIf}
727
728         ; --------------
729         ; Files
730         ; --------------
731
732         ReadRegStr $R0 HKLM "${MyRegPath}" "ExecutableName"
733         ${IfThen} "$R0" == "" ${|} StrCpy $R0 "LameXP.exe" ${|}
734         ExecWait '"$INSTDIR\$R0" --uninstall'
735
736         Delete /REBOOTOK "$INSTDIR\$R0"
737         !insertmacro CleanUpFiles /REBOOTOK
738         RMDir "$INSTDIR"
739
740         ; --------------
741         ; Registry
742         ; --------------
743         
744         DeleteRegKey HKLM "${MyRegPath}"
745         DeleteRegKey HKCU "${MyRegPath}"
746
747         DeleteRegKey HKLM "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{54dcbccb-c905-46dc-b6e6-48563d0e9e55}"
748         DeleteRegKey HKCU "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{54dcbccb-c905-46dc-b6e6-48563d0e9e55}"
749         
750         DeleteRegKey HKLM "${AppPaths}\LameXP.exe"
751         DeleteRegKey HKCU "${AppPaths}\LameXP.exe"
752
753         MessageBox MB_YESNO|MB_TOPMOST "$(LAMEXP_LANG_UNINST_PERSONAL)" IDNO +3
754         Delete "$LOCALAPPDATA\LoRd_MuldeR\LameXP - Audio Encoder Front-End\config.ini"
755         Delete "$INSTDIR\*.ini"
756
757         !insertmacro PrintProgress "$(MUI_UNTEXT_FINISH_TITLE)."
758 SectionEnd
759
760
761 ;--------------------------------
762 ;Check For Update Mode
763 ;--------------------------------
764
765 Function SkipIfUnattended
766         ${IfThen} ${UnattendedMode} ${|} Abort ${|}
767 FunctionEnd
768
769 Function CheckForUpdate
770         ${If} "$INSTDIR" == ""
771         ${OrIf} "$INSTDIR" == "$EXEDIR"
772         ${OrIfNot} ${FileExists} "$INSTDIR\LameXP.exe"
773                 Return
774         ${EndIf}
775
776         FindWindow $R0 "#32770" "" $HWNDPARENT
777         GetDlgItem $R1 $R0 1019
778         EnableWindow $R1 0
779
780         FindWindow $R0 "#32770" "" $HWNDPARENT
781         GetDlgItem $R1 $R0 1001
782         EnableWindow $R1 0
783 FunctionEnd
784
785 Function un.CheckForcedUninstall
786         ${IfThen} ${ForcedMode} ${|} Abort ${|}
787 FunctionEnd
788
789
790 ;--------------------------------
791 ;Check For Pre-Release
792 ;--------------------------------
793
794 Function CheckForPreRelease
795         !ifdef LAMEXP_IS_PRERELEASE
796                 ${IfNot} ${UnattendedMode}
797                         MessageBox MB_TOPMOST|MB_ICONEXCLAMATION|MB_OKCANCEL "$(LAMEXP_LANG_PRERELEASE_WARNING)" /SD IDOK IDOK +2
798                         Quit
799                 ${EndIf}
800         !endif
801 FunctionEnd
802
803
804 ;--------------------------------
805 ;Locked List
806 ;--------------------------------
807
808 !macro _LockedListShow uinst
809         !insertmacro MUI_HEADER_TEXT "$(LAMEXP_LANG_LOCKEDLIST_HEADER)" "$(LAMEXP_LANG_LOCKEDLIST_TEXT)"
810         ${If} ${UnattendedMode}
811                 !insertmacro DisableBackButton $R0
812         ${EndIf}
813         ${If} ${RunningX64}
814                 InitPluginsDir
815                 File /oname=$PLUGINSDIR\LockedList64.dll `${NSISDIR}\Plugins\LockedList64.dll`
816         ${EndIf}
817         !insertmacro GetExecutableName $R0
818         LockedList::AddModule "\$R0"
819         ${If} "$R0" != "LameXP.exe"
820                 LockedList::AddModule "\LameXP.exe"
821         ${EndIf}
822         LockedList::AddModule "\Uninstall.exe"
823         !if ${uinst} < 1
824                 LockedList::AddModule "\Au_.exe"
825         !endif
826         #LockedList::AddFolder "$INSTDIR"
827         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)"
828         Pop $R0
829 !macroend
830
831 Function LockedListShow
832         !insertmacro _LockedListShow 0
833 FunctionEnd
834
835 Function un.LockedListShow
836         !insertmacro _LockedListShow 1
837 FunctionEnd
838
839
840 ;--------------------------------
841 ;Install Success
842 ;--------------------------------
843
844 Function RunAppFunction
845         !insertmacro DisableNextButton $R0
846         !insertmacro GetExecutableName $R0
847         ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR" "explore" ""
848         ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\$R0" "open" "--first-run"
849 FunctionEnd
850
851 Function ShowReadmeFunction
852         !insertmacro DisableNextButton $R0
853         ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\Manual.html" "open" ""
854 FunctionEnd
855
856 Function .onInstSuccess
857         ${If} ${UnattendedMode}
858                 !insertmacro GetExecutableName $R0
859                 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\$R0" "open" "--first-run"
860         ${EndIf}
861 FunctionEnd