OSDN Git Service

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