Happy new year 2016!
[LameXP.git] / etc / NSIS / setup.nsi
blob7b67bafd4f4322258c9a673bb61b5096abcf3a6e
1 ; ///////////////////////////////////////////////////////////////////////////////
2 ; // LameXP - Audio Encoder Front-End
3 ; // Copyright (C) 2004-2016 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.
9 ; //
10 ; // This program is distributed in the hope that it will be useful,
11 ; // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ; // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ; // GNU General Public License for more details.
14 ; //
15 ; // You should have received a copy of the GNU General Public License along
16 ; // with this program; if not, write to the Free Software Foundation, Inc.,
17 ; // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 ; //
19 ; // http://www.gnu.org/licenses/gpl-2.0.txt
20 ; ///////////////////////////////////////////////////////////////////////////////
23 ;--------------------------------
24 ;Basic Defines
25 ;--------------------------------
27 !ifndef NSIS_UNICODE
28 !error "NSIS_UNICODE is undefined, please compile with Unicode NSIS !!!"
29 !endif
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 !ifndef LAMEXP_UPX_PATH
53 !error "LAMEXP_UPX_PATH is not defined !!!"
54 !endif
56 ;UUID
57 !define MyRegPath "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{FBD7A67D-D700-4043-B54F-DD106D00F308}"
59 ;App Paths
60 !define AppPaths "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths"
62 ;Web-Site
63 !define MyWebSite "http://muldersoft.com/"
66 ;--------------------------------
67 ;Check for Pre-Release
68 ;--------------------------------
70 !define LAMEXP_IS_PRERELEASE
72 !if '${LAMEXP_INSTTYPE}' == 'Final'
73 !undef LAMEXP_IS_PRERELEASE
74 !endif
75 !if '${LAMEXP_INSTTYPE}' == 'Hotfix'
76 !undef LAMEXP_IS_PRERELEASE
77 !endif
80 ;--------------------------------
81 ;Manifest
82 ;--------------------------------
84 !tempfile PACKHDRTEMP
85 !packhdr "${PACKHDRTEMP}" '"..\Utilities\MT.exe" -manifest "setup.manifest" -outputresource:"${PACKHDRTEMP};1"'
88 ;--------------------------------
89 ;Includes
90 ;--------------------------------
92 !include `MUI2.nsh`
93 !include `WinVer.nsh`
94 !include `x64.nsh`
95 !include `StdUtils.nsh`
98 ;--------------------------------
99 ;Installer Attributes
100 ;--------------------------------
102 RequestExecutionLevel admin
103 ShowInstDetails show
104 ShowUninstDetails show
105 Name "LameXP v${LAMEXP_VERSION} ${LAMEXP_INSTTYPE}-${LAMEXP_PATCH} [Build #${LAMEXP_BUILD}]"
106 OutFile "${LAMEXP_OUTPUT_FILE}"
107 BrandingText "Date created: ${LAMEXP_DATE} [Build #${LAMEXP_BUILD}]"
108 InstallDir "$PROGRAMFILES\MuldeR\LameXP v${LAMEXP_VERSION}"
109 InstallDirRegKey HKLM "${MyRegPath}" "InstallLocation"
112 ;--------------------------------
113 ;Compressor
114 ;--------------------------------
116 SetCompressor /SOLID LZMA
117 SetCompressorDictSize 64
119 #!packhdr "$%TEMP%\exehead.tmp" '"${LAMEXP_UPX_PATH}\upx.exe" --brute "$%TEMP%\exehead.tmp"'
122 ;--------------------------------
123 ;Reserved Files
124 ;--------------------------------
126 ReserveFile "${NSISDIR}\Plugins\Aero.dll"
127 ReserveFile "${NSISDIR}\Plugins\LangDLL.dll"
128 ReserveFile "${NSISDIR}\Plugins\LockedList.dll"
129 ReserveFile "${NSISDIR}\Plugins\LockedList64.dll"
130 ReserveFile "${NSISDIR}\Plugins\nsDialogs.dll"
131 ReserveFile "${NSISDIR}\Plugins\nsExec.dll"
132 ReserveFile "${NSISDIR}\Plugins\StartMenu.dll"
133 ReserveFile "${NSISDIR}\Plugins\StdUtils.dll"
134 ReserveFile "${NSISDIR}\Plugins\System.dll"
135 ReserveFile "${NSISDIR}\Plugins\UserInfo.dll"
138 ;--------------------------------
139 ;Variables
140 ;--------------------------------
142 Var StartMenuFolder
145 ;--------------------------------
146 ;Version Info
147 ;--------------------------------
149 !searchreplace PRODUCT_VERSION_DATE "${LAMEXP_DATE}" "-" "."
150 VIProductVersion "${PRODUCT_VERSION_DATE}.${LAMEXP_BUILD}"
152 VIAddVersionKey "Author" "LoRd_MuldeR <mulder2@gmx.de>"
153 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."
154 VIAddVersionKey "CompanyName" "Free Software Foundation"
155 VIAddVersionKey "FileDescription" "LameXP v${LAMEXP_VERSION} ${LAMEXP_INSTTYPE}-${LAMEXP_PATCH} [Build #${LAMEXP_BUILD}]"
156 VIAddVersionKey "FileVersion" "${PRODUCT_VERSION_DATE}.${LAMEXP_BUILD} (${LAMEXP_VERSION})"
157 VIAddVersionKey "LegalCopyright" "Copyright 2004-2016 LoRd_MuldeR"
158 VIAddVersionKey "LegalTrademarks" "GNU"
159 VIAddVersionKey "OriginalFilename" "LameXP.${LAMEXP_DATE}.exe"
160 VIAddVersionKey "ProductName" "LameXP - Audio Encoder Frontend"
161 VIAddVersionKey "ProductVersion" "${LAMEXP_VERSION}, Build #${LAMEXP_BUILD} (${LAMEXP_DATE})"
162 VIAddVersionKey "Website" "${MyWebSite}"
165 ;--------------------------------
166 ;MUI2 Interface Settings
167 ;--------------------------------
169 !define MUI_ABORTWARNING
170 !define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
171 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${MyRegPath}"
172 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "StartmenuFolder"
173 !define MUI_LANGDLL_REGISTRY_ROOT HKLM
174 !define MUI_LANGDLL_REGISTRY_KEY "${MyRegPath}"
175 !define MUI_LANGDLL_REGISTRY_VALUENAME "SetupLanguage"
176 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "LameXP v${LAMEXP_VERSION}"
177 !define MUI_FINISHPAGE_NOAUTOCLOSE
178 !define MUI_UNFINISHPAGE_NOAUTOCLOSE
179 !define MUI_FINISHPAGE_RUN
180 !define MUI_FINISHPAGE_RUN_FUNCTION RunAppFunction
181 !define MUI_FINISHPAGE_SHOWREADME
182 !define MUI_FINISHPAGE_SHOWREADME_FUNCTION ShowReadmeFunction
183 !define MUI_FINISHPAGE_LINK ${MyWebSite}
184 !define MUI_FINISHPAGE_LINK_LOCATION ${MyWebSite}
185 !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico"
186 !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall.ico"
187 !define MUI_WELCOMEFINISHPAGE_BITMAP "wizard.bmp"
188 !define MUI_UNWELCOMEFINISHPAGE_BITMAP "wizard-un.bmp"
189 !define MUI_HEADERIMAGE
190 !define MUI_HEADERIMAGE_BITMAP "header.bmp"
191 !define MUI_HEADERIMAGE_UNBITMAP "header-un.bmp"
192 !define MUI_LANGDLL_ALLLANGUAGES
193 !define MUI_CUSTOMFUNCTION_GUIINIT MyGuiInit
194 !define MUI_CUSTOMFUNCTION_UNGUIINIT un.MyGuiInit
195 !define MUI_LANGDLL_ALWAYSSHOW
198 ;--------------------------------
199 ;MUI2 Pages (Installer)
200 ;--------------------------------
202 ;Welcome
203 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
204 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE CheckForPreRelease
205 !define MUI_WELCOMEPAGE_TITLE_3LINES
206 !define MUI_FINISHPAGE_TITLE_3LINES
207 !insertmacro MUI_PAGE_WELCOME
209 ;License
210 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
211 !insertmacro MUI_PAGE_LICENSE "license.rtf"
213 ;Directory
214 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
215 !define MUI_PAGE_CUSTOMFUNCTION_SHOW CheckForUpdate
216 !insertmacro MUI_PAGE_DIRECTORY
218 ;Startmenu
219 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
220 !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
222 ;LockedList
223 Page Custom LockedListShow
225 ;Install Files
226 !insertmacro MUI_PAGE_INSTFILES
228 ;Finish
229 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
230 !insertmacro MUI_PAGE_FINISH
233 ;--------------------------------
234 ;MUI2 Pages (Uninstaller)
235 ;--------------------------------
237 ;Welcome
238 !define MUI_WELCOMEPAGE_TITLE_3LINES
239 !define MUI_FINISHPAGE_TITLE_3LINES
240 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.CheckForcedUninstall
241 !insertmacro MUI_UNPAGE_WELCOME
243 ;Confirm
244 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.CheckForcedUninstall
245 !insertmacro MUI_UNPAGE_CONFIRM
247 ;LockedList
248 UninstPage Custom un.LockedListShow
250 ;Uninstall
251 !insertmacro MUI_UNPAGE_INSTFILES
253 ;Finish
254 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.CheckForcedUninstall
255 !insertmacro MUI_UNPAGE_FINISH
258 ;--------------------------------
259 ;Languages
260 ;--------------------------------
262 !insertmacro MUI_LANGUAGE "English" ;first language is the default language
263 !insertmacro MUI_LANGUAGE "German"
264 !insertmacro MUI_LANGUAGE "Spanish"
265 !insertmacro MUI_LANGUAGE "Russian"
266 !insertmacro MUI_LANGUAGE "Ukrainian"
267 !insertmacro MUI_LANGUAGE "Polish"
268 !insertmacro MUI_LANGUAGE "Hungarian"
270 ; !insertmacro MUI_LANGUAGE "French"
271 ; !insertmacro MUI_LANGUAGE "SpanishInternational"
272 ; !insertmacro MUI_LANGUAGE "SimpChinese"
273 ; !insertmacro MUI_LANGUAGE "TradChinese"
274 ; !insertmacro MUI_LANGUAGE "Japanese"
275 ; !insertmacro MUI_LANGUAGE "Italian"
276 ; !insertmacro MUI_LANGUAGE "Dutch"
277 ; !insertmacro MUI_LANGUAGE "Greek"
278 ; !insertmacro MUI_LANGUAGE "Romanian"
279 ; !insertmacro MUI_LANGUAGE "Serbian"
280 ; !insertmacro MUI_LANGUAGE "SerbianLatin"
281 ; !insertmacro MUI_LANGUAGE "Arabic"
282 ; !insertmacro MUI_LANGUAGE "Portuguese"
283 ; !insertmacro MUI_LANGUAGE "Afrikaans"
284 ; !insertmacro MUI_LANGUAGE "Malay"
285 ; !insertmacro MUI_LANGUAGE "Indonesian"
288 ;--------------------------------
289 ;Translation
290 ;--------------------------------
292 ;English
293 !include "..\Translation\Blank.nsh"
295 ;German
296 !include "..\Translation\LameXP_DE.nsh"
298 ;Spanish
299 !include "..\Translation\LameXP_ES.nsh"
301 ;Russian
302 !include "..\Translation\LameXP_RU.nsh"
304 ;Ukrainian
305 !include "..\Translation\LameXP_UK.nsh"
307 ;Polish
308 !include "..\Translation\LameXP_PL.nsh"
310 ;Hungarian
311 !include "..\Translation\LameXP_HU.nsh"
314 ;--------------------------------
315 ;LogicLib Extensions
316 ;--------------------------------
318 !macro _UnattendedMode _a _b _t _f
319 !insertmacro _LOGICLIB_TEMP
320 ${StdUtils.TestParameter} $_LOGICLIB_TEMP "Update"
321 StrCmp "$_LOGICLIB_TEMP" "true" `${_t}` `${_f}`
322 !macroend
323 !define UnattendedMode `"" UnattendedMode ""`
325 !macro _ForcedMode _a _b _t _f
326 !insertmacro _LOGICLIB_TEMP
327 ${StdUtils.TestParameter} $_LOGICLIB_TEMP "Force"
328 StrCmp "$_LOGICLIB_TEMP" "true" `${_t}` `${_f}`
329 !macroend
330 !define ForcedMode `"" ForcedMode ""`
332 !macro _ValidFileName _a _b _t _f
333 !insertmacro _LOGICLIB_TEMP
334 ${StdUtils.ValidFileName} $_LOGICLIB_TEMP `${_b}`
335 StrCmp "$_LOGICLIB_TEMP" "ok" `${_t}` `${_f}`
336 !macroend
337 !define ValidFileName `"" ValidFileName`
340 ;--------------------------------
341 ;Installer initialization
342 ;--------------------------------
344 Function .onInit
345 InitPluginsDir
347 ; --------
349 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "{2B3D1EBF-B3B6-4E93-92B9-6853029A7162}") i .r1 ?e'
350 Pop $0
351 ${If} $0 <> 0
352 MessageBox MB_ICONSTOP|MB_TOPMOST "Sorry, the installer is already running!"
353 Quit
354 ${EndIf}
356 ; --------
358 # Running on Windows NT family?
359 ${IfNot} ${IsNT}
360 MessageBox MB_TOPMOST|MB_ICONSTOP "Sorry, this application does *not* support Windows 9x or Windows ME!"
361 ExecShell "open" "http://windows.microsoft.com/"
362 Quit
363 ${EndIf}
365 # Running on Windows XP or later?
366 ${If} ${AtMostWin2000}
367 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)."
368 ExecShell "open" "http://windows.microsoft.com/"
369 Quit
370 ${EndIf}
372 # If on Windows XP, is the required Service Pack installed?
373 ${If} ${IsWinXP}
374 ${IfNot} ${RunningX64} # Windows XP 32-Bit, requires Service Pack 3
375 ${AndIf} ${AtMostServicePack} 2
376 MessageBox MB_TOPMOST|MB_ICONEXCLAMATION "This application requires Windows XP with Service Pack 3 installed!"
377 ${If} ${Cmd} `MessageBox MB_TOPMOST|MB_ICONQUESTION|MB_YESNO "Do you want to download Service Pack 3 for Windows XP now?" IDYES`
378 ExecShell "open" "http://www.microsoft.com/en-us/download/details.aspx?id=24"
379 ${Else}
380 ExecShell "open" "http://windowsupdate.microsoft.com/"
381 ${EndIf}
382 Quit
383 ${EndIf}
384 ${If} ${RunningX64} # Windows XP 64-Bit, requires Service Pack 2
385 ${AndIf} ${AtMostServicePack} 1
386 MessageBox MB_TOPMOST|MB_ICONEXCLAMATION "This application requires Windows XP x64 Edition with Service Pack 2 installed!"
387 ${If} ${Cmd} `MessageBox MB_TOPMOST|MB_ICONQUESTION|MB_YESNO "Do you want to download Service Pack 2 for Windows XP x64 Edition now?" IDYES`
388 ExecShell "open" "http://www.microsoft.com/en-us/download/details.aspx?id=17791"
389 ${Else}
390 ExecShell "open" "http://windowsupdate.microsoft.com/"
391 ${EndIf}
392 Quit
393 ${EndIf}
394 ${EndIf}
396 ; --------
398 ${IfNot} ${UnattendedMode}
399 !insertmacro MUI_LANGDLL_DISPLAY
400 ${EndIf}
402 ; --------
404 UserInfo::GetAccountType
405 Pop $0
406 ${If} $0 != "Admin"
407 MessageBox MB_ICONSTOP|MB_TOPMOST "Your system requires administrative permissions in order to install this software."
408 SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
409 Quit
410 ${EndIf}
411 FunctionEnd
413 Function un.onInit
414 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "{2B3D1EBF-B3B6-4E93-92B9-6853029A7162}") i .r1 ?e'
415 Pop $0
416 ${If} $0 <> 0
417 MessageBox MB_ICONSTOP|MB_TOPMOST "Sorry, the un-installer is already running!"
418 Quit
419 ${EndIf}
421 ${IfNot} ${ForcedMode}
422 !insertmacro MUI_LANGDLL_DISPLAY
423 ${EndIf}
425 ; --------
427 UserInfo::GetAccountType
428 Pop $0
429 ${If} $0 != "Admin"
430 MessageBox MB_ICONSTOP|MB_TOPMOST "Your system requires administrative permissions in order to install this software."
431 SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
432 Quit
433 ${EndIf}
434 FunctionEnd
437 ;--------------------------------
438 ;GUI initialization
439 ;--------------------------------
441 Function MyGuiInit
442 StrCpy $0 $HWNDPARENT
443 System::Call "user32::SetWindowPos(i r0, i -1, i 0, i 0, i 0, i 0, i 3)"
444 Aero::Apply
445 FunctionEnd
447 Function un.MyGuiInit
448 StrCpy $0 $HWNDPARENT
449 System::Call "user32::SetWindowPos(i r0, i -1, i 0, i 0, i 0, i 0, i 3)"
450 Aero::Apply
451 FunctionEnd
454 ;--------------------------------
455 ;Macros & Auxiliary Functions
456 ;--------------------------------
458 !macro PrintProgress Text
459 SetDetailsPrint textonly
460 DetailPrint '${Text}'
461 SetDetailsPrint listonly
462 Sleep 1000
463 !macroend
465 !macro CreateWebLink ShortcutFile TargetURL
466 Push $0
467 Push $1
468 StrCpy $0 "${ShortcutFile}"
469 StrCpy $1 "${TargetURL}"
470 Call _CreateWebLink
471 Pop $1
472 Pop $0
473 !macroend
475 Function _CreateWebLink
476 FlushINI "$0"
477 SetFileAttributes "$0" FILE_ATTRIBUTE_NORMAL
478 DeleteINISec "$0" "DEFAULT"
479 DeleteINISec "$0" "InternetShortcut"
480 WriteINIStr "$0" "DEFAULT" "BASEURL" "$1"
481 WriteINIStr "$0" "InternetShortcut" "ORIGURL" "$1"
482 WriteINIStr "$0" "InternetShortcut" "URL" "$1"
483 WriteINIStr "$0" "InternetShortcut" "IconFile" "$SYSDIR\SHELL32.dll"
484 WriteINIStr "$0" "InternetShortcut" "IconIndex" "150"
485 FlushINI "$0"
486 SetFileAttributes "$0" FILE_ATTRIBUTE_READONLY
487 FunctionEnd
489 !macro GetExecutableName OutVar
490 ${StdUtils.GetParameter} ${OutVar} "Update" ""
491 ${StdUtils.TrimStr} ${OutVar}
492 ${If} "${OutVar}" == ""
493 ${OrIfNot} ${ValidFileName} "${OutVar}"
494 StrCpy ${OutVar} "LameXP.exe"
495 ${EndIf}
496 !macroend
498 !macro DisableNextButton TmpVar
499 GetDlgItem ${TmpVar} $HWNDPARENT 1
500 EnableWindow ${TmpVar} 0
501 !macroend
503 !macro DisableBackButton TmpVar
504 GetDlgItem ${TmpVar} $HWNDPARENT 3
505 EnableWindow ${TmpVar} 0
506 !macroend
508 !macro CleanUpFiles options
509 Delete ${options} "$INSTDIR\Changelog.htm"
510 Delete ${options} "$INSTDIR\Changelog.html"
511 Delete ${options} "$INSTDIR\Contributors.txt"
512 Delete ${options} "$INSTDIR\Copying.txt"
513 Delete ${options} "$INSTDIR\FAQ.html"
514 Delete ${options} "$INSTDIR\Howto.html"
515 Delete ${options} "$INSTDIR\LameEnc.sys"
516 Delete ${options} "$INSTDIR\LameXP.exe"
517 Delete ${options} "$INSTDIR\LameXP.exe.sig"
518 Delete ${options} "$INSTDIR\LameXP-Portable.exe"
519 Delete ${options} "$INSTDIR\License.txt"
520 Delete ${options} "$INSTDIR\Manual.html"
521 Delete ${options} "$INSTDIR\Readme.htm"
522 Delete ${options} "$INSTDIR\ReadMe.txt"
523 Delete ${options} "$INSTDIR\PRE_RELEASE_INFO.txt"
524 Delete ${options} "$INSTDIR\Settings.cfg"
525 Delete ${options} "$INSTDIR\Translate.html"
526 Delete ${options} "$INSTDIR\Uninstall.exe"
527 Delete ${options} "$INSTDIR\Qt*.dll"
528 Delete ${options} "$INSTDIR\MUtils*.dll"
529 Delete ${options} "$INSTDIR\msvcr*.dll"
530 Delete ${options} "$INSTDIR\msvcp*.dll"
531 Delete ${options} "$INSTDIR\concrt*.dll"
532 Delete ${options} "$INSTDIR\vcruntime*.dll"
533 Delete ${options} "$INSTDIR\vccorlib*.dll"
534 Delete ${options} "$INSTDIR\api-ms-*.dll"
535 Delete ${options} "$INSTDIR\ucrtbase.dll"
537 RMDir /r ${options} "$INSTDIR\cache"
538 RMDir /r ${options} "$INSTDIR\img"
539 RMDir /r ${options} "$INSTDIR\imageformats"
540 RMDir /r ${options} "$INSTDIR\redist"
541 !macroend
543 ;--------------------------------
544 ;Install Files
545 ;--------------------------------
547 Section "-PreInit"
548 SetShellVarContext all
549 SetOutPath "$INSTDIR"
550 SectionEnd
552 Section "-Clean Up Old Cruft"
553 !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_CLEANUP)"
554 !insertmacro CleanUpFiles ""
555 SectionEnd
557 Section "!Install Files"
558 !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_INSTFILES)"
560 DeleteOldBinary:
561 !insertmacro GetExecutableName $R0
562 ClearErrors
563 Delete "$INSTDIR\$R0"
565 ${If} ${Errors}
566 MessageBox MB_TOPMOST|MB_ICONSTOP|MB_RETRYCANCEL 'Could not delete old "$R0" file. Is LameXP still running?' IDRETRY DeleteOldBinary
567 Abort "Could not delete old binary!"
568 ${EndIf}
570 File /a `/oname=$R0` `${LAMEXP_SOURCE_PATH}\LameXP.exe`
571 File /nonfatal /a /r `${LAMEXP_SOURCE_PATH}\*.dll`
573 File /a /r `${LAMEXP_SOURCE_PATH}\*.txt`
574 File /a /r `${LAMEXP_SOURCE_PATH}\*.html`
575 File /a /r `${LAMEXP_SOURCE_PATH}\*.png`
576 SectionEnd
578 # Section "-Install VCRedist"
579 # !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_VCREDIST)"
580 # File /a `/oname=$PLUGINSDIR\vcredist_x86.exe` `${LAMEXP_SOURCE_PATH}\redist\vcredist_x86.exe`
581 # ExecWait '"$PLUGINSDIR\vcredist_x86.exe" /install /passive /norestart'
582 # SectionEnd
584 Section "-Write Uninstaller"
585 !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_MAKEUNINST)"
586 WriteUninstaller "$INSTDIR\Uninstall.exe"
587 SectionEnd
589 Section "-Create Shortcuts"
590 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
591 !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_SHORTCUTS)"
592 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
594 SetShellVarContext current
596 Delete "$SMPROGRAMS\$StartMenuFolder\*.lnk"
597 Delete "$SMPROGRAMS\$StartMenuFolder\*.pif"
598 Delete "$SMPROGRAMS\$StartMenuFolder\*.url"
600 SetShellVarContext all
602 Delete "$SMPROGRAMS\$StartMenuFolder\*.lnk"
603 Delete "$SMPROGRAMS\$StartMenuFolder\*.pif"
604 Delete "$SMPROGRAMS\$StartMenuFolder\*.url"
606 !insertmacro GetExecutableName $R0
608 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk" "$INSTDIR\$R0" "" "$INSTDIR\$R0" 0
609 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_LICENSE).lnk" "$INSTDIR\License.txt"
610 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_CHANGELOG).lnk" "$INSTDIR\Changelog.html"
611 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_TRANSLATE).lnk" "$INSTDIR\Translate.html"
612 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_MANUAL).lnk" "$INSTDIR\Manual.html"
613 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_UNINSTALL).lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0
615 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Official LameXP Homepage.url" "${MyWebSite}"
616 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Doom9's Forum.url" "http://forum.doom9.org/"
617 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Bug Tracker.url" "https://github.com/lordmulder/LameXP/issues"
618 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\RareWares.org.url" "http://rarewares.org/"
619 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Hydrogenaudio Forums.url" "http://www.hydrogenaudio.org/"
621 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk"
622 ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "LameXP.lnk" ${StdUtils.Const.ISV_PinToTaskbar}
623 DetailPrint 'Pin: "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk" -> $R1'
624 ${EndIf}
625 !insertmacro MUI_STARTMENU_WRITE_END
626 SectionEnd
628 Section "-Update Registry"
629 !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_REGISTRY)"
631 !insertmacro GetExecutableName $R0
632 WriteRegStr HKLM "${MyRegPath}" "InstallLocation" "$INSTDIR"
633 WriteRegStr HKLM "${MyRegPath}" "ExecutableName" "$R0"
634 WriteRegStr HKLM "${MyRegPath}" "DisplayIcon" "$INSTDIR\$R0,0"
635 WriteRegStr HKLM "${MyRegPath}" "UninstallString" '"$INSTDIR\Uninstall.exe"'
636 WriteRegStr HKLM "${MyRegPath}" "DisplayName" "LameXP v${LAMEXP_VERSION}"
637 WriteRegStr HKLM "${MyRegPath}" "Publisher" "LoRd_MuldeR <mulder2@gmx.de>"
638 WriteRegStr HKLM "${MyRegPath}" "DisplayVersion" "${LAMEXP_VERSION} ${LAMEXP_INSTTYPE}-${LAMEXP_PATCH} [Build #${LAMEXP_BUILD}]"
639 WriteRegStr HKLM "${MyRegPath}" "URLInfoAbout" "${MyWebSite}"
640 WriteRegStr HKLM "${MyRegPath}" "URLUpdateInfo" "${MyWebSite}"
642 WriteRegStr HKLM "${AppPaths}\LameXP.exe" "" "$INSTDIR\$R0"
643 WriteRegStr HKLM "${AppPaths}\LameXP.exe" "Path" "$INSTDIR"
644 SectionEnd
646 Section "-Finished"
647 !insertmacro PrintProgress "$(MUI_TEXT_FINISH_TITLE)."
649 !ifdef LAMEXP_IS_PRERELEASE
650 ${If} ${FileExists} "$INSTDIR\PRE_RELEASE_INFO.txt"
651 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\PRE_RELEASE_INFO.txt" "open" ""
652 ${EndIf}
653 !endif
655 ${IfThen} ${UnattendedMode} ${|} SetAutoClose true ${|}
656 SectionEnd
659 ;--------------------------------
660 ;Uninstaller
661 ;--------------------------------
663 Section "Uninstall"
664 SetOutPath "$EXEDIR"
665 !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_UNINSTALL)"
667 ; --------------
668 ; Startmenu
669 ; --------------
671 !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
672 ${IfNot} "$StartMenuFolder" == ""
673 SetShellVarContext current
674 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk"
675 ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "LameXP.lnk" ${StdUtils.Const.ISV_UnpinFromTaskbar}
676 DetailPrint 'Unpin: "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk" -> $R1'
677 ${EndIf}
678 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\*.*"
679 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.lnk"
680 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.url"
681 RMDir "$SMPROGRAMS\$StartMenuFolder"
682 ${EndIf}
684 SetShellVarContext all
685 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk"
686 ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "LameXP.lnk" ${StdUtils.Const.ISV_UnpinFromTaskbar}
687 DetailPrint 'Unpin: "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk" -> $R1'
688 ${EndIf}
689 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\*.*"
690 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.lnk"
691 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.url"
692 RMDir "$SMPROGRAMS\$StartMenuFolder"
693 ${EndIf}
694 ${EndIf}
696 ; --------------
697 ; Files
698 ; --------------
700 ReadRegStr $R0 HKLM "${MyRegPath}" "ExecutableName"
701 ${IfThen} "$R0" == "" ${|} StrCpy $R0 "LameXP.exe" ${|}
702 ExecWait '"$INSTDIR\$R0" --uninstall'
704 Delete /REBOOTOK "$INSTDIR\$R0"
705 !insertmacro CleanUpFiles /REBOOTOK
706 RMDir "$INSTDIR"
708 ; --------------
709 ; Registry
710 ; --------------
712 DeleteRegKey HKLM "${MyRegPath}"
713 DeleteRegKey HKCU "${MyRegPath}"
715 DeleteRegKey HKLM "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{54dcbccb-c905-46dc-b6e6-48563d0e9e55}"
716 DeleteRegKey HKCU "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{54dcbccb-c905-46dc-b6e6-48563d0e9e55}"
718 DeleteRegKey HKLM "${AppPaths}\LameXP.exe"
719 DeleteRegKey HKCU "${AppPaths}\LameXP.exe"
721 MessageBox MB_YESNO|MB_TOPMOST "$(LAMEXP_LANG_UNINST_PERSONAL)" IDNO +3
722 Delete "$LOCALAPPDATA\LoRd_MuldeR\LameXP - Audio Encoder Front-End\config.ini"
723 Delete "$INSTDIR\*.ini"
725 !insertmacro PrintProgress "$(MUI_UNTEXT_FINISH_TITLE)."
726 SectionEnd
729 ;--------------------------------
730 ;Check For Update Mode
731 ;--------------------------------
733 Function SkipIfUnattended
734 ${IfThen} ${UnattendedMode} ${|} Abort ${|}
735 FunctionEnd
737 Function CheckForUpdate
738 ${If} "$INSTDIR" == ""
739 ${OrIf} "$INSTDIR" == "$EXEDIR"
740 ${OrIfNot} ${FileExists} "$INSTDIR\LameXP.exe"
741 Return
742 ${EndIf}
744 FindWindow $R0 "#32770" "" $HWNDPARENT
745 GetDlgItem $R1 $R0 1019
746 EnableWindow $R1 0
748 FindWindow $R0 "#32770" "" $HWNDPARENT
749 GetDlgItem $R1 $R0 1001
750 EnableWindow $R1 0
751 FunctionEnd
753 Function un.CheckForcedUninstall
754 ${IfThen} ${ForcedMode} ${|} Abort ${|}
755 FunctionEnd
758 ;--------------------------------
759 ;Check For Pre-Release
760 ;--------------------------------
762 Function CheckForPreRelease
763 !ifdef LAMEXP_IS_PRERELEASE
764 ${IfNot} ${UnattendedMode}
765 MessageBox MB_TOPMOST|MB_ICONEXCLAMATION|MB_OKCANCEL "$(LAMEXP_LANG_PRERELEASE_WARNING)" /SD IDOK IDOK +2
766 Quit
767 ${EndIf}
768 !endif
769 FunctionEnd
772 ;--------------------------------
773 ;Locked List
774 ;--------------------------------
776 !macro _LockedListShow uinst
777 !insertmacro MUI_HEADER_TEXT "$(LAMEXP_LANG_LOCKEDLIST_HEADER)" "$(LAMEXP_LANG_LOCKEDLIST_TEXT)"
778 ${If} ${UnattendedMode}
779 !insertmacro DisableBackButton $R0
780 ${EndIf}
781 ${If} ${RunningX64}
782 InitPluginsDir
783 File /oname=$PLUGINSDIR\LockedList64.dll `${NSISDIR}\Plugins\LockedList64.dll`
784 ${EndIf}
785 !insertmacro GetExecutableName $R0
786 LockedList::AddModule "\$R0"
787 ${If} "$R0" != "LameXP.exe"
788 LockedList::AddModule "\LameXP.exe"
789 ${EndIf}
790 LockedList::AddModule "\Uninstall.exe"
791 !if ${uinst} < 1
792 LockedList::AddModule "\Au_.exe"
793 !endif
794 LockedList::AddFolder "$INSTDIR"
795 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)"
796 Pop $R0
797 !macroend
799 Function LockedListShow
800 !insertmacro _LockedListShow 0
801 FunctionEnd
803 Function un.LockedListShow
804 !insertmacro _LockedListShow 1
805 FunctionEnd
808 ;--------------------------------
809 ;Install Success
810 ;--------------------------------
812 Function RunAppFunction
813 !insertmacro DisableNextButton $R0
814 !insertmacro GetExecutableName $R0
815 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR" "explore" ""
816 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\$R0" "open" "--first-run"
817 FunctionEnd
819 Function ShowReadmeFunction
820 !insertmacro DisableNextButton $R0
821 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\Manual.html" "open" ""
822 FunctionEnd
824 Function .onInstSuccess
825 ${If} ${UnattendedMode}
826 !insertmacro GetExecutableName $R0
827 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\$R0" "open" "--first-run"
828 ${EndIf}
829 FunctionEnd