OSDN Git Service

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