OSDN Git Service

Small installer fix.
[x264-launcher/x264-launcher.git] / etc / setup / setup.nsi
1 ; ///////////////////////////////////////////////////////////////////////////////
2 ; // Simple x264 Launcher
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 ; ///////////////////////////////////////////////////////////////////////////////
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 X264_BUILD
32   !error "X264_BUILD is not defined !!!"
33 !endif
34 !ifndef X264_DATE
35   !error "X264_DATE is not defined !!!"
36 !endif
37 !ifndef X264_OUTPUT_FILE
38   !error "X264_OUTPUT_FILE is not defined !!!"
39 !endif
40 !ifndef X264_SOURCE_PATH
41   !error "X264_SOURCE_PATH is not defined !!!"
42 !endif
43
44 ;UUID
45 !define MyRegPath "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{986E454F-DACA-4326-A9C7-3E46C0BFFDCE}"
46
47 ;Web-Site
48 !define MyWebSite "http://muldersoft.com/"
49
50 ;App Paths
51 !define AppPaths "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths"
52
53
54 ;--------------------------------
55 ;Manifest
56 ;--------------------------------
57
58 !tempfile PACKHDRTEMP
59 !packhdr "${PACKHDRTEMP}" '"..\..\..\Prerequisites\MSVC\redist\bin\mt.exe" -manifest "setup.manifest" -outputresource:"${PACKHDRTEMP};1" && "..\..\..\Prerequisites\UPX\upx.exe" --brute "${PACKHDRTEMP}"'
60
61
62 ;--------------------------------
63 ;Includes
64 ;--------------------------------
65
66 !include `MUI2.nsh`
67 !include `WinVer.nsh`
68 !include `x64.nsh`
69 !include `StdUtils.nsh`
70
71
72 ;--------------------------------
73 ;Installer Attributes
74 ;--------------------------------
75
76 RequestExecutionLevel admin
77 ShowInstDetails show
78 ShowUninstDetails show
79 Name "Simple x264/x265 Launcher [Build #${X264_BUILD}]"
80 OutFile "${X264_OUTPUT_FILE}"
81 BrandingText "Date created: ${X264_DATE} [Build #${X264_BUILD}]"
82 InstallDir "$PROGRAMFILES\MuldeR\Simple x264 Launcher v2"
83 InstallDirRegKey HKLM "${MyRegPath}" "InstallLocation"
84
85
86 ;--------------------------------
87 ;Compressor
88 ;--------------------------------
89
90 SetCompressor /SOLID LZMA
91 SetCompressorDictSize 64
92
93
94 ;--------------------------------
95 ;Reserved Files
96 ;--------------------------------
97
98 ReserveFile "${NSISDIR}\Plugins\Aero.dll"
99 ReserveFile "${NSISDIR}\Plugins\LangDLL.dll"
100 ReserveFile "${NSISDIR}\Plugins\LockedList.dll"
101 ReserveFile "${NSISDIR}\Plugins\LockedList64.dll"
102 ReserveFile "${NSISDIR}\Plugins\nsDialogs.dll"
103 ReserveFile "${NSISDIR}\Plugins\nsExec.dll"
104 ReserveFile "${NSISDIR}\Plugins\StartMenu.dll"
105 ReserveFile "${NSISDIR}\Plugins\StdUtils.dll"
106 ReserveFile "${NSISDIR}\Plugins\System.dll"
107 ReserveFile "${NSISDIR}\Plugins\UserInfo.dll"
108
109
110 ;--------------------------------
111 ;Variables
112 ;--------------------------------
113
114 Var StartMenuFolder
115 Var UpdateNotificationShown
116
117
118 ;--------------------------------
119 ;Version Info
120 ;--------------------------------
121
122 !searchreplace PRODUCT_VERSION_DATE "${X264_DATE}" "-" "."
123 VIProductVersion "${PRODUCT_VERSION_DATE}.${X264_BUILD}"
124
125 VIAddVersionKey "Author" "LoRd_MuldeR <mulder2@gmx.de>"
126 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."
127 VIAddVersionKey "CompanyName" "Free Software Foundation"
128 VIAddVersionKey "FileDescription" "Simple x264 Launcher [Build #${X264_BUILD}]"
129 VIAddVersionKey "FileVersion" "${PRODUCT_VERSION_DATE}.${X264_BUILD}"
130 VIAddVersionKey "LegalCopyright" "Copyright 2004-2016 LoRd_MuldeR"
131 VIAddVersionKey "LegalTrademarks" "GNU"
132 VIAddVersionKey "OriginalFilename" "x264_x64.${X264_DATE}.exe"
133 VIAddVersionKey "ProductName" "Simple x264 Launcher"
134 VIAddVersionKey "ProductVersion" "Build #${X264_BUILD} (${X264_DATE})"
135 VIAddVersionKey "Website" "${MyWebSite}"
136
137
138 ;--------------------------------
139 ;MUI2 Interface Settings
140 ;--------------------------------
141
142 !define MUI_ABORTWARNING
143 !define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
144 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${MyRegPath}"
145 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "StartmenuFolder"
146 !define MUI_LANGDLL_REGISTRY_ROOT HKLM
147 !define MUI_LANGDLL_REGISTRY_KEY "${MyRegPath}"
148 !define MUI_LANGDLL_REGISTRY_VALUENAME "SetupLanguage"
149 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "Simple x264 Launcher v2"
150 !define MUI_FINISHPAGE_NOAUTOCLOSE
151 !define MUI_UNFINISHPAGE_NOAUTOCLOSE
152 !define MUI_FINISHPAGE_RUN
153 !define MUI_FINISHPAGE_RUN_FUNCTION RunAppFunction
154 !define MUI_FINISHPAGE_SHOWREADME
155 !define MUI_FINISHPAGE_SHOWREADME_FUNCTION ShowReadmeFunction
156 !define MUI_FINISHPAGE_LINK ${MyWebSite}
157 !define MUI_FINISHPAGE_LINK_LOCATION ${MyWebSite}
158 !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico"
159 !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall.ico"
160 !define MUI_WELCOMEFINISHPAGE_BITMAP "wizard.bmp"
161 !define MUI_UNWELCOMEFINISHPAGE_BITMAP "wizard-un.bmp"
162 !define MUI_HEADERIMAGE
163 !define MUI_HEADERIMAGE_BITMAP "header.bmp"
164 !define MUI_HEADERIMAGE_UNBITMAP "header-un.bmp"
165 !define MUI_LANGDLL_ALLLANGUAGES
166 !define MUI_CUSTOMFUNCTION_GUIINIT MyGuiInit
167 !define MUI_CUSTOMFUNCTION_UNGUIINIT un.MyGuiInit
168 !define MUI_LANGDLL_ALWAYSSHOW
169
170
171 ;--------------------------------
172 ;MUI2 Pages (Installer)
173 ;--------------------------------
174
175 ;Welcome
176 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
177 !define MUI_WELCOMEPAGE_TITLE_3LINES
178 !define MUI_FINISHPAGE_TITLE_3LINES
179 !insertmacro MUI_PAGE_WELCOME
180
181 ;License
182 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
183 !insertmacro MUI_PAGE_LICENSE "license.rtf"
184
185 ;Directory
186 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
187 !define MUI_PAGE_CUSTOMFUNCTION_SHOW CheckForUpdate
188 !insertmacro MUI_PAGE_DIRECTORY
189
190 ;Startmenu
191 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
192 !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
193
194 ;LockedList
195 Page Custom LockedListShow
196
197 ;Install Files
198 !insertmacro MUI_PAGE_INSTFILES
199
200 ;Finish
201 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
202 !insertmacro MUI_PAGE_FINISH
203
204
205 ;--------------------------------
206 ;MUI2 Pages (Uninstaller)
207 ;--------------------------------
208
209 ;Welcome
210 !define MUI_WELCOMEPAGE_TITLE_3LINES
211 !define MUI_FINISHPAGE_TITLE_3LINES
212 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.CheckForcedUninstall
213 !insertmacro MUI_UNPAGE_WELCOME
214
215 ;Confirm
216 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.CheckForcedUninstall
217 !insertmacro MUI_UNPAGE_CONFIRM
218
219 ;LockedList
220 UninstPage Custom un.LockedListShow
221
222 ;Uninstall
223 !insertmacro MUI_UNPAGE_INSTFILES
224
225 ;Finish
226 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.CheckForcedUninstall
227 !insertmacro MUI_UNPAGE_FINISH
228
229
230 ;--------------------------------
231 ;Languages
232 ;--------------------------------
233  
234 !insertmacro MUI_LANGUAGE "English" ;first language is the default language
235
236 ; !insertmacro MUI_LANGUAGE "German"
237 ; !insertmacro MUI_LANGUAGE "Spanish"
238 ; !insertmacro MUI_LANGUAGE "Russian"
239 ; !insertmacro MUI_LANGUAGE "Ukrainian"
240 ; !insertmacro MUI_LANGUAGE "Polish"
241
242 ; !insertmacro MUI_LANGUAGE "French"
243 ; !insertmacro MUI_LANGUAGE "SpanishInternational"
244 ; !insertmacro MUI_LANGUAGE "SimpChinese"
245 ; !insertmacro MUI_LANGUAGE "TradChinese"
246 ; !insertmacro MUI_LANGUAGE "Japanese"
247 ; !insertmacro MUI_LANGUAGE "Italian"
248 ; !insertmacro MUI_LANGUAGE "Dutch"
249 ; !insertmacro MUI_LANGUAGE "Greek"
250 ; !insertmacro MUI_LANGUAGE "Hungarian"
251 ; !insertmacro MUI_LANGUAGE "Romanian"
252 ; !insertmacro MUI_LANGUAGE "Serbian"
253 ; !insertmacro MUI_LANGUAGE "SerbianLatin"
254 ; !insertmacro MUI_LANGUAGE "Arabic"
255 ; !insertmacro MUI_LANGUAGE "Portuguese"
256 ; !insertmacro MUI_LANGUAGE "Afrikaans"
257 ; !insertmacro MUI_LANGUAGE "Malay"
258 ; !insertmacro MUI_LANGUAGE "Indonesian"
259
260
261 ;--------------------------------
262 ;Translation
263 ;--------------------------------
264
265 ;English
266 !include "language\en.nsh"
267
268
269 ;--------------------------------
270 ;LogicLib Extensions
271 ;--------------------------------
272
273 !macro _UnattendedMode _a _b _t _f
274         !insertmacro _LOGICLIB_TEMP
275         ${StdUtils.TestParameter} $_LOGICLIB_TEMP "Update"
276         StrCmp "$_LOGICLIB_TEMP" "true" `${_t}` `${_f}`
277 !macroend
278 !define UnattendedMode `"" UnattendedMode ""`
279
280 !macro _ForcedMode _a _b _t _f
281         !insertmacro _LOGICLIB_TEMP
282         ${StdUtils.TestParameter} $_LOGICLIB_TEMP "Force"
283         StrCmp "$_LOGICLIB_TEMP" "true" `${_t}` `${_f}`
284 !macroend
285 !define ForcedMode `"" ForcedMode ""`
286
287 !macro _ValidFileName _a _b _t _f
288         !insertmacro _LOGICLIB_TEMP
289         ${StdUtils.ValidFileName} $_LOGICLIB_TEMP `${_b}`
290         StrCmp "$_LOGICLIB_TEMP" "ok" `${_t}` `${_f}`
291 !macroend
292 !define ValidFileName `"" ValidFileName`
293
294
295 ;--------------------------------
296 ;Installer initialization
297 ;--------------------------------
298
299 Function .onInit
300         InitPluginsDir
301
302         ; --------
303
304         System::Call 'kernel32::CreateMutexA(i 0, i 0, t "{2B3D1EBF-B3B6-4E93-92B9-6853029A7162}") i .r1 ?e'
305         Pop $0
306         ${If} $0 <> 0
307                 MessageBox MB_ICONSTOP|MB_TOPMOST "Sorry, the installer is already running!"
308                 Quit
309         ${EndIf}
310
311         ; --------
312         
313         # Running on Windows NT family?
314         ${IfNot} ${IsNT}
315                 MessageBox MB_TOPMOST|MB_ICONSTOP "Sorry, this application does *not* support Windows 9x or Windows ME!"
316                 ExecShell "open" "http://windows.microsoft.com/"
317                 Quit
318         ${EndIf}
319
320         # Running on Windows XP or later?
321         ${If} ${AtMostWin2000}
322                 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)."
323                 ExecShell "open" "http://windows.microsoft.com/"
324                 Quit
325         ${EndIf}
326
327         # If on Windows XP, is the required Service Pack installed?
328         ${If} ${IsWinXP}
329                 ${IfNot} ${RunningX64} # Windows XP 32-Bit, requires Service Pack 3
330                 ${AndIf} ${AtMostServicePack} 2
331                         MessageBox MB_TOPMOST|MB_ICONEXCLAMATION "This application requires Windows XP with Service Pack 3 installed.$\nWindows XP *without* Service Pack 3 reached end-of-life on 2010-07-13.$\nCurrent Windows XP (Service Pack 3) will be supported until 2014-04-08.$\n$\nPlease install Service Pack 3 now or just run Windows Update!"
332                         ${If} ${Cmd} `MessageBox MB_TOPMOST|MB_ICONQUESTION|MB_YESNO "Do you want to download Service Pack 3 for Windows XP now?" IDYES`
333                                 ExecShell "open" "http://www.microsoft.com/en-us/download/details.aspx?id=24"
334                         ${Else}
335                                 ExecShell "open" "http://windowsupdate.microsoft.com/"
336                         ${EndIf}
337                         Quit
338                 ${EndIf}
339                 ${If} ${RunningX64} # Windows XP 64-Bit, requires Service Pack 2
340                 ${AndIf} ${AtMostServicePack} 1
341                         MessageBox MB_TOPMOST|MB_ICONEXCLAMATION "This application requires Windows XP x64 Edition with Service Pack 2 installed.$\nWindows XP x64 Edition *without* Service Pack 2 reached end-of-life on 2009-04-14.$\nCurrent Windows XP x64 Edition (Service Pack 2) will be supported until 2014-04-08.$\n$\nPlease install Service Pack 2 now or just run Windows Update!"
342                         ${If} ${Cmd} `MessageBox MB_TOPMOST|MB_ICONQUESTION|MB_YESNO "Do you want to download Service Pack 2 for Windows XP x64 Edition now?" IDYES`
343                                 ExecShell "open" "http://www.microsoft.com/en-us/download/details.aspx?id=17791"
344                         ${Else}
345                                 ExecShell "open" "http://windowsupdate.microsoft.com/"
346                         ${EndIf}
347                         Quit
348                 ${EndIf}
349         ${EndIf}
350
351         ; --------
352
353         ${IfNot} ${UnattendedMode}
354                 !insertmacro MUI_LANGDLL_DISPLAY
355         ${EndIf}
356
357         ; --------
358
359         UserInfo::GetAccountType
360         Pop $0
361         ${If} $0 != "Admin"
362                 MessageBox MB_ICONSTOP|MB_TOPMOST "Your system requires administrative permissions in order to install this software."
363                 SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
364                 Quit
365         ${EndIf}
366 FunctionEnd
367
368 Function un.onInit
369         System::Call 'kernel32::CreateMutexA(i 0, i 0, t "{2B3D1EBF-B3B6-4E93-92B9-6853029A7162}") i .r1 ?e'
370         Pop $0
371         ${If} $0 <> 0
372                 MessageBox MB_ICONSTOP|MB_TOPMOST "Sorry, the un-installer is already running!"
373                 Quit
374         ${EndIf}
375
376         ${IfNot} ${ForcedMode}
377                 !insertmacro MUI_LANGDLL_DISPLAY
378         ${EndIf}
379         
380         ; --------
381
382         UserInfo::GetAccountType
383         Pop $0
384         ${If} $0 != "Admin"
385                 MessageBox MB_ICONSTOP|MB_TOPMOST "Your system requires administrative permissions in order to install this software."
386                 SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
387                 Quit
388         ${EndIf}
389 FunctionEnd
390
391
392 ;--------------------------------
393 ;GUI initialization
394 ;--------------------------------
395
396 Function MyGuiInit
397         StrCpy $0 $HWNDPARENT
398         System::Call "user32::SetWindowPos(i r0, i -1, i 0, i 0, i 0, i 0, i 3)"
399         Aero::Apply
400 FunctionEnd
401
402 Function un.MyGuiInit
403         StrCpy $0 $HWNDPARENT
404         System::Call "user32::SetWindowPos(i r0, i -1, i 0, i 0, i 0, i 0, i 3)"
405         Aero::Apply
406 FunctionEnd
407
408
409 ;--------------------------------
410 ;Macros & Auxiliary Functions
411 ;--------------------------------
412
413 !macro PrintProgress Text
414         SetDetailsPrint textonly
415         DetailPrint '${Text}'
416         SetDetailsPrint listonly
417         Sleep 1000
418 !macroend
419
420 !macro CreateWebLink ShortcutFile TargetURL
421         Push $0
422         Push $1
423         StrCpy $0 "${ShortcutFile}"
424         StrCpy $1 "${TargetURL}"
425         Call _CreateWebLink
426         Pop $1
427         Pop $0
428 !macroend
429
430 Function _CreateWebLink
431         FlushINI "$0"
432         SetFileAttributes "$0" FILE_ATTRIBUTE_NORMAL
433         DeleteINISec "$0" "DEFAULT"
434         DeleteINISec "$0" "InternetShortcut"
435         WriteINIStr "$0" "DEFAULT" "BASEURL" "$1"
436         WriteINIStr "$0" "InternetShortcut" "ORIGURL" "$1"
437         WriteINIStr "$0" "InternetShortcut" "URL" "$1"
438         WriteINIStr "$0" "InternetShortcut" "IconFile" "$SYSDIR\SHELL32.dll"
439         WriteINIStr "$0" "InternetShortcut" "IconIndex" "150"
440         FlushINI "$0"
441         SetFileAttributes "$0" FILE_ATTRIBUTE_READONLY
442 FunctionEnd
443
444 !macro GetExecutableName OutVar
445         ${StdUtils.GetParameter} ${OutVar} "Update" ""
446         ${StdUtils.TrimStr} ${OutVar}
447         ${If} "${OutVar}" == ""
448         ${OrIfNot} ${ValidFileName} "${OutVar}"
449                 StrCpy ${OutVar} "x264_launcher.exe"
450         ${EndIf}
451 !macroend
452
453 !macro DisableNextButton TmpVar
454         GetDlgItem ${TmpVar} $HWNDPARENT 1
455         EnableWindow ${TmpVar} 0
456 !macroend
457
458 !macro DisableBackButton TmpVar
459         GetDlgItem ${TmpVar} $HWNDPARENT 3
460         EnableWindow ${TmpVar} 0
461 !macroend
462
463 !macro CleanUpFiles options
464         Delete ${options} `$INSTDIR\*.exe`
465         Delete ${options} `$INSTDIR\*.dll`
466         Delete ${options} `$INSTDIR\*.txt`
467         Delete ${options} `$INSTDIR\*.htm`
468         Delete ${options} `$INSTDIR\*.html`
469         
470         RMDir /r ${options} `$INSTDIR\toolset`
471         RMDir /r ${options} `$INSTDIR\imageformats`
472         RMDir /r ${options} `$INSTDIR\sources`
473 !macroend
474
475 !macro SetControlEnabled item_id enable
476         FindWindow $R0 "#32770" "" $HWNDPARENT
477         ${IfNot} $R0 == 0
478                 GetDlgItem $R1 $R0 ${item_id}
479                 EnableWindow $R1 ${enable}
480         ${EndIf}
481 !macroend
482
483 !macro SkipToNextPage
484         GetDlgItem $R0 $HWNDPARENT 1
485         System::Call "User32::PostMessage(i $HWNDPARENT, i ${WM_COMMAND}, i 1, i $R0)"
486 !macroend
487
488
489 ;--------------------------------
490 ;Install Files
491 ;--------------------------------
492
493 Section "-PreInit"
494         SetShellVarContext all
495         SetOutPath "$INSTDIR"
496 SectionEnd
497
498 Section "-Clean Up Old Cruft"
499         !insertmacro PrintProgress "$(X264_LANG_STATUS_CLEANUP)"
500         !insertmacro CleanUpFiles ""
501 SectionEnd
502
503 Section "!Install Files"
504         !insertmacro PrintProgress "$(X264_LANG_STATUS_INSTFILES)"
505         
506         DeleteOldBinary:
507         !insertmacro GetExecutableName $R0
508         ClearErrors
509         Delete "$INSTDIR\$R0"
510         
511         ${If} ${Errors}
512                 MessageBox MB_TOPMOST|MB_ICONSTOP|MB_RETRYCANCEL 'Could not delete old "$R0" file. Is program still running?' IDRETRY DeleteOldBinary
513                 Abort "Could not delete old binary!"
514         ${EndIf}
515
516         File /a `/oname=$R0` `${X264_SOURCE_PATH}\x264_launcher.exe`
517
518         File /a `${X264_SOURCE_PATH}\*.dll`
519         File /a `${X264_SOURCE_PATH}\*.txt`
520         File /a `${X264_SOURCE_PATH}\*.html`
521
522         SetOutPath "$INSTDIR\imageformats"
523         File /a /r `${X264_SOURCE_PATH}\imageformats\*.*`
524
525         SetOutPath "$INSTDIR\toolset"
526         File /a /r `${X264_SOURCE_PATH}\toolset\*.*`
527
528         SetOutPath "$INSTDIR\sources"
529         File /a /r `${X264_SOURCE_PATH}\sources\*.*`
530 SectionEnd
531
532 Section "-Write Uinstaller"
533         !insertmacro PrintProgress "$(X264_LANG_STATUS_MAKEUNINST)"
534         WriteUninstaller "$INSTDIR\Uninstall.exe"
535 SectionEnd
536
537 Section "-Create Shortcuts"
538         !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
539                 !insertmacro PrintProgress "$(X264_LANG_STATUS_SHORTCUTS)"
540                 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
541                 
542                 SetShellVarContext current
543                 
544                 Delete "$SMPROGRAMS\$StartMenuFolder\*.lnk"
545                 Delete "$SMPROGRAMS\$StartMenuFolder\*.pif"
546                 Delete "$SMPROGRAMS\$StartMenuFolder\*.url"
547                 
548                 SetShellVarContext all
549                 
550                 Delete "$SMPROGRAMS\$StartMenuFolder\*.lnk"
551                 Delete "$SMPROGRAMS\$StartMenuFolder\*.pif"
552                 Delete "$SMPROGRAMS\$StartMenuFolder\*.url"
553
554                 !insertmacro GetExecutableName $R0
555                 
556                 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Simple x264 Launcher.lnk"        "$INSTDIR\$R0" "" "$INSTDIR\$R0" 0
557                 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(X264_LANG_LINK_LICENSE).lnk"   "$INSTDIR\LICENSE.html"
558                 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(X264_LANG_LINK_MANUAL).lnk"    "$INSTDIR\README.html"
559                 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(X264_LANG_LINK_CHANGELOG).lnk" "$INSTDIR\HISTORY.txt"
560                 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(X264_LANG_LINK_UNINSTALL).lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0
561                 
562                 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\MuldeR's Homepage.url" "${MyWebSite}"
563                 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Doom9's Forum.url"     "http://forum.doom9.org/"
564                 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\x264.com.url"          "http://x264.com/"
565                 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\x265.com.url"          "http://x265.org/"
566                 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Avisynth Wiki.url"     "http://avisynth.nl/"
567                 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\VapourSynth.com.url"   "http://www.vapoursynth.com/"
568
569                 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\Simple x264 Launcher.lnk"
570                         ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "Simple x264 Launcher.lnk" ${StdUtils.Const.ShellVerb.PinToTaskbar}
571                         DetailPrint 'Pin: "$SMPROGRAMS\$StartMenuFolder\Simple x264 Launcher.lnk" -> $R1'
572                 ${EndIf}
573         !insertmacro MUI_STARTMENU_WRITE_END
574 SectionEnd
575
576 Section "-Update Registry"
577         !insertmacro PrintProgress "$(X264_LANG_STATUS_REGISTRY)"
578
579         !insertmacro GetExecutableName $R0
580         WriteRegStr HKLM "${MyRegPath}" "InstallLocation" "$INSTDIR"
581         WriteRegStr HKLM "${MyRegPath}" "ExecutableName" "$R0"
582         WriteRegStr HKLM "${MyRegPath}" "DisplayIcon" "$INSTDIR\$R0,0"
583         WriteRegStr HKLM "${MyRegPath}" "UninstallString" '"$INSTDIR\Uninstall.exe"'
584         WriteRegStr HKLM "${MyRegPath}" "DisplayName" "Simple x264 Launcher v2"
585         WriteRegStr HKLM "${MyRegPath}" "Publisher" "LoRd_MuldeR <mulder2@gmx.de>"
586         WriteRegStr HKLM "${MyRegPath}" "DisplayVersion" "Build #${X264_BUILD} (${X264_DATE})"
587         WriteRegStr HKLM "${MyRegPath}" "URLInfoAbout" "${MyWebSite}"
588         WriteRegStr HKLM "${MyRegPath}" "URLUpdateInfo" "${MyWebSite}"
589         
590         DeleteRegKey HKCU "${AppPaths}\x264_launcher.exe"
591         WriteRegStr HKLM "${AppPaths}\x264_launcher.exe" "" "$INSTDIR\$R0"
592         WriteRegStr HKLM "${AppPaths}\x264_launcher.exe" "Path" "$INSTDIR"
593 SectionEnd
594
595 Section "-Finished"
596         !insertmacro PrintProgress "$(MUI_TEXT_FINISH_TITLE)."
597         ${IfThen} ${UnattendedMode} ${|} SetAutoClose true ${|}
598 SectionEnd
599
600
601 ;--------------------------------
602 ;Uninstaller
603 ;--------------------------------
604
605 Section "Uninstall"
606         SetOutPath "$EXEDIR"
607         !insertmacro PrintProgress "$(X264_LANG_STATUS_UNINSTALL)"
608
609         ; --------------
610         ; Startmenu
611         ; --------------
612         
613         !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
614         ${IfNot} "$StartMenuFolder" == ""
615                 SetShellVarContext current
616                 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\Simple x264 Launcher.lnk"
617                         ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "Simple x264 Launcher.lnk" ${StdUtils.Const.ShellVerb.UnpinFromTaskbar}
618                         DetailPrint 'Unpin: "$SMPROGRAMS\$StartMenuFolder\Simple x264 Launcher.lnk" -> $R1'
619                 ${EndIf}
620                 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\*.*"
621                         Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.lnk"
622                         Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.url"
623                         RMDir "$SMPROGRAMS\$StartMenuFolder"
624                 ${EndIf}
625                 
626                 SetShellVarContext all
627                 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\Simple x264 Launcher.lnk"
628                         ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "Simple x264 Launcher.lnk" ${StdUtils.Const.ShellVerb.UnpinFromTaskbar}
629                         DetailPrint 'Unpin: "$SMPROGRAMS\$StartMenuFolder\Simple x264 Launcher.lnk" -> $R1'
630                 ${EndIf}
631                 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\*.*"
632                         Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.lnk"
633                         Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.url"
634                         RMDir "$SMPROGRAMS\$StartMenuFolder"
635                 ${EndIf}
636         ${EndIf}
637
638         ; --------------
639         ; Files
640         ; --------------
641
642         ReadRegStr $R0 HKLM "${MyRegPath}" "ExecutableName"
643         ${IfThen} "$R0" == "" ${|} StrCpy $R0 "x264_launcher.exe" ${|}
644
645         Delete /REBOOTOK "$INSTDIR\$R0"
646         !insertmacro CleanUpFiles /REBOOTOK
647         RMDir "$INSTDIR"
648
649         ; --------------
650         ; Registry
651         ; --------------
652         
653         DeleteRegKey HKLM "${MyRegPath}"
654         DeleteRegKey HKCU "${MyRegPath}"
655
656         DeleteRegKey HKLM "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{54dcbccb-c905-46dc-b6e6-48563d0e9e55}"
657         DeleteRegKey HKCU "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{54dcbccb-c905-46dc-b6e6-48563d0e9e55}"
658         
659         DeleteRegKey HKLM "${AppPaths}\x264_launcher.exe"
660         DeleteRegKey HKCU "${AppPaths}\x264_launcher.exe"
661
662         MessageBox MB_YESNO|MB_TOPMOST "$(X264_LANG_UNINST_PERSONAL)" IDNO +3
663         Delete "$LOCALAPPDATA\LoRd_MuldeR\Simple x264 Launcher\*.ini"
664         RMDir "$LOCALAPPDATA\LoRd_MuldeR\Simple x264 Launcher"
665
666         !insertmacro PrintProgress "$(MUI_UNTEXT_FINISH_TITLE)."
667 SectionEnd
668
669
670 ;--------------------------------
671 ;Check For Update Mode
672 ;--------------------------------
673
674 Function SkipIfUnattended
675         ${IfThen} ${UnattendedMode} ${|} Abort ${|}
676 FunctionEnd
677
678 Function CheckForUpdate
679         ${If} "$INSTDIR" == ""
680         ${OrIf} "$INSTDIR" == "$EXEDIR"
681         ${OrIfNot} ${FileExists} "$INSTDIR\x264_launcher.exe"
682                 StrCpy $UpdateNotificationShown FALSE
683                 !insertmacro SetControlEnabled 1019 1
684                 !insertmacro SetControlEnabled 1001 1
685                 Return
686         ${Else}
687                 !insertmacro SetControlEnabled 1019 0
688                 !insertmacro SetControlEnabled 1001 0
689                 ${If} "$UpdateNotificationShown" != TRUE
690                         StrCpy $UpdateNotificationShown TRUE
691                         MessageBox MB_ICONINFORMATION|MB_TOPMOST "$(X264_LANG_UNINST_UPDATE_MODE)"
692                         !insertmacro SkipToNextPage
693                 ${EndIf}
694         ${EndIf}
695 FunctionEnd
696
697 Function un.CheckForcedUninstall
698         ${IfThen} ${ForcedMode} ${|} Abort ${|}
699 FunctionEnd
700
701
702 ;--------------------------------
703 ;Locked List
704 ;--------------------------------
705
706 !macro _LockedListShow uinst
707         !insertmacro MUI_HEADER_TEXT "$(X264_LANG_LOCKEDLIST_HEADER)" "$(X264_LANG_LOCKEDLIST_TEXT)"
708         ${If} ${UnattendedMode}
709                 !insertmacro DisableBackButton $R0
710         ${EndIf}
711         ${If} ${RunningX64}
712                 InitPluginsDir
713                 File /oname=$PLUGINSDIR\LockedList64.dll `${NSISDIR}\Plugins\LockedList64.dll`
714         ${EndIf}
715         !insertmacro GetExecutableName $R0
716         LockedList::AddModule "\$R0"
717         ${If} "$R0" != "x264_launcher.exe"
718                 LockedList::AddModule "\x264_launcher.exe"
719         ${EndIf}
720         LockedList::AddModule "\Uninstall.exe"
721         !if ${uinst} < 1
722                 LockedList::AddModule "\Au_.exe"
723         !endif
724         #LockedList::AddFolder "$INSTDIR"
725         LockedList::Dialog /autonext /heading "$(X264_LANG_LOCKEDLIST_HEADING)" /noprograms "$(X264_LANG_LOCKEDLIST_NOPROG)" /searching  "$(X264_LANG_LOCKEDLIST_SEARCH)" /colheadings "$(X264_LANG_LOCKEDLIST_COLHDR1)" "$(X264_LANG_LOCKEDLIST_COLHDR2)"
726         Pop $R0
727 !macroend
728
729 Function LockedListShow
730         !insertmacro _LockedListShow 0
731 FunctionEnd
732
733 Function un.LockedListShow
734         !insertmacro _LockedListShow 1
735 FunctionEnd
736
737
738 ;--------------------------------
739 ;Install Success
740 ;--------------------------------
741
742 Function RunAppFunction
743         !insertmacro DisableNextButton $R0
744         !insertmacro GetExecutableName $R0
745         ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR" "explore" ""
746         ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\$R0" "open" "--first-run"
747 FunctionEnd
748
749 Function ShowReadmeFunction
750         !insertmacro DisableNextButton $R0
751         ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\README.html" "open" ""
752 FunctionEnd
753
754 Function .onInstSuccess
755         ${If} ${UnattendedMode}
756                 !insertmacro GetExecutableName $R0
757                 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR" "explore" ""
758                 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\$R0" "open" "--first-run"
759         ${EndIf}
760 FunctionEnd