cdda: fix reported ts not in sync after a seek
[vlc.git] / extras / package / win32 / NSIS / vlc.win32.nsi.in
1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ; NSIS installer script for vlc ;
3 ; (http://nsis.sourceforge.net) ;
4 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5
6 !define PRODUCT_NAME "VLC media player"
7 !define VERSION @VERSION@
8 !define PRODUCT_VERSION @VERSION@
9 !define PRODUCT_GROUP "VideoLAN"
10 !define PRODUCT_PUBLISHER "VideoLAN"
11 !define PRODUCT_WEB_SITE "https://www.videolan.org/"
12 !define PRODUCT_DIR_REGKEY "Software\VideoLAN\VLC"
13 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
14 !define PRODUCT_UNINST_ROOT_KEY "HKLM"
15 !define PRODUCT_ID "{ea92ef52-afe4-4212-bacb-dfe9fca94cd6}"
16
17 !define MUI_LANGDLL_REGISTRY_ROOT "HKLM"
18 !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_DIR_REGKEY}"
19 !define MUI_LANGDLL_REGISTRY_VALUENAME "Language"
20
21 !define MEMENTO_REGISTRY_ROOT ${PRODUCT_UNINST_ROOT_KEY}
22 !define MEMENTO_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
23
24 @HAVE_WIN64_TRUE@ !define VLC_64BIT_INSTALLER
25
26 ManifestDPIAware true
27 Unicode true
28
29 !define INSTALL_ACTIVEX
30 !define INSTALL_MOZILLA
31
32 Var ReinstallType
33 Var ReinstallUninstallBtn
34 Var PerformUpdate
35 Var PreviousVersion
36 Var PreviousVersionState
37 Var PreviousInstallDir
38 Var UninstallLog
39
40 Var 32bitUninstaller
41 Var 32bitPath
42
43 ;;;;;;;;;;;;;;;;;;;;;;;;;
44 ; General configuration ;
45 ;;;;;;;;;;;;;;;;;;;;;;;;;
46
47 Name "${PRODUCT_NAME}"
48 @HAVE_WIN64_FALSE@ OutFile ..\vlc-${VERSION}-win32.exe
49 @HAVE_WIN64_TRUE@  OutFile ..\vlc-${VERSION}-win64.exe
50 InstallDir "$@PROGRAMFILES@\VideoLAN\VLC"
51 !ifdef NSIS_LZMA_COMPRESS_WHOLE
52 SetCompressor lzma
53 !else
54 SetCompressor /SOLID lzma
55 !endif
56
57 SetOverwrite ifdiff
58 CRCCheck on
59 BrandingText "${PRODUCT_GROUP} ${PRODUCT_NAME}"
60
61 InstType "$(Name_InstTypeRecommended)"
62 InstType "$(Name_InstTypeMinimum)"
63 InstType "$(Name_InstTypeFull)"
64
65 RequestExecutionLevel admin
66 !addincludedir NSIS
67 !addplugindir NSIS
68 !include nsProcess.nsh
69 !include WinVer.nsh
70 !include FileFunc.nsh
71 !include MUI2.nsh
72 !include Memento.nsh
73
74 !insertmacro GetParameters
75 !insertmacro GetOptions
76
77 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
78 ; NSIS Modern User Interface configuration ;
79 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
80
81 ; MUI Settings
82   !define MUI_ABORTWARNING
83   !define MUI_ICON "vlc.ico"
84   !define MUI_UNICON "vlc.ico"
85   !define MUI_COMPONENTSPAGE_SMALLDESC
86
87   ; Banner (welcome and finish page) for installer
88   !define MUI_WELCOMEFINISHPAGE_BITMAP "NSIS/vlc_branding.bmp"
89   ; Banner for uninstaller
90   !define MUI_UNWELCOMEFINISHPAGE_BITMAP "NSIS/vlc_branding.bmp"
91
92 ; Installer pages
93   ; Welcome page
94     !define MUI_PAGE_CUSTOMFUNCTION_PRE PageFastUpdatePre
95     !define MUI_WELCOMEPAGE_TITLE_3LINES
96     !insertmacro MUI_PAGE_WELCOME
97   ; Optional update page
98     Page custom PageReinstall PageLeaveReinstall
99   ; License page
100     !define MUI_LICENSEPAGE_BUTTON $(^NextBtn)
101     !define MUI_LICENSEPAGE_TEXT_BOTTOM "$(License_NextText)"
102     !define MUI_PAGE_CUSTOMFUNCTION_PRE PageSkipPre
103     !insertmacro MUI_PAGE_LICENSE "COPYING.txt"
104   ; Components page
105     !define MUI_PAGE_CUSTOMFUNCTION_PRE PageComponentsPre
106     !insertmacro MUI_PAGE_COMPONENTS
107   ; Directory page
108     !define MUI_PAGE_CUSTOMFUNCTION_PRE PageDirectoryPre
109     !insertmacro MUI_PAGE_DIRECTORY
110   ; Instfiles page
111     !insertmacro MUI_PAGE_INSTFILES
112   ; Finish page
113     !define MUI_PAGE_CUSTOMFUNCTION_PRE PageFastUpdatePre
114     !define MUI_FINISHPAGE_RUN
115     !define MUI_FINISHPAGE_RUN_FUNCTION AppExecAs
116     !define MUI_FINISHPAGE_LINK "$(Link_VisitWebsite)"
117     !define MUI_FINISHPAGE_LINK_LOCATION "https://www.videolan.org/vlc/"
118     !define MUI_FINISHPAGE_NOREBOOTSUPPORT
119     !insertmacro MUI_PAGE_FINISH
120
121 ; Uninstaller pages
122     !insertmacro MUI_UNPAGE_CONFIRM
123     !insertmacro MUI_UNPAGE_COMPONENTS
124     !insertmacro MUI_UNPAGE_INSTFILES
125     !insertmacro MUI_UNPAGE_FINISH
126
127   !addincludedir "languages"
128   !define VLC_LANGFILE_FALLBACK "EnglishExtra.nsh"
129
130 ; Language files (first language is default)
131   !insertmacro MUI_LANGUAGE "English"
132   !insertmacro LANGFILE_INCLUDE "EnglishExtra.nsh"
133
134   !insertmacro MUI_LANGUAGE "French"
135   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "FrenchExtra.nsh" ${VLC_LANGFILE_FALLBACK}
136   !insertmacro MUI_LANGUAGE "German"
137   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "GermanExtra.nsh" ${VLC_LANGFILE_FALLBACK}
138   !insertmacro MUI_LANGUAGE "Spanish"
139   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "SpanishExtra.nsh" ${VLC_LANGFILE_FALLBACK}
140   !insertmacro MUI_LANGUAGE "SimpChinese"
141   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "SimpChineseExtra.nsh" ${VLC_LANGFILE_FALLBACK}
142   !insertmacro MUI_LANGUAGE "TradChinese"
143   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "TradChineseExtra.nsh" ${VLC_LANGFILE_FALLBACK}
144   !insertmacro MUI_LANGUAGE "Japanese"
145   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "JapaneseExtra.nsh" ${VLC_LANGFILE_FALLBACK}
146   !insertmacro MUI_LANGUAGE "Italian"
147   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "ItalianExtra.nsh" ${VLC_LANGFILE_FALLBACK}
148   !insertmacro MUI_LANGUAGE "Dutch"
149   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "DutchExtra.nsh" ${VLC_LANGFILE_FALLBACK}
150   !insertmacro MUI_LANGUAGE "Danish"
151   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "DanishExtra.nsh" ${VLC_LANGFILE_FALLBACK}
152   !insertmacro MUI_LANGUAGE "Swedish"
153   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "SwedishExtra.nsh" ${VLC_LANGFILE_FALLBACK}
154   !insertmacro MUI_LANGUAGE "Finnish"
155   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "FinnishExtra.nsh" ${VLC_LANGFILE_FALLBACK}
156   !insertmacro MUI_LANGUAGE "Russian"
157   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "RussianExtra.nsh" ${VLC_LANGFILE_FALLBACK}
158   !insertmacro MUI_LANGUAGE "Portuguese"
159   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "PortugueseExtra.nsh" ${VLC_LANGFILE_FALLBACK}
160   !insertmacro MUI_LANGUAGE "PortugueseBR"
161   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "PortugueseBRExtra.nsh" ${VLC_LANGFILE_FALLBACK}
162   !insertmacro MUI_LANGUAGE "Welsh"
163   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "WelshExtra.nsh" ${VLC_LANGFILE_FALLBACK}
164   !insertmacro MUI_LANGUAGE "Uzbek"
165   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "UzbekExtra.nsh" ${VLC_LANGFILE_FALLBACK}
166   !insertmacro MUI_LANGUAGE "Ukrainian"
167   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "UkrainianExtra.nsh" ${VLC_LANGFILE_FALLBACK}
168   !insertmacro MUI_LANGUAGE "Turkish"
169   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "TurkishExtra.nsh" ${VLC_LANGFILE_FALLBACK}
170   !insertmacro MUI_LANGUAGE "Thai"
171   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "ThaiExtra.nsh" ${VLC_LANGFILE_FALLBACK}
172   !insertmacro MUI_LANGUAGE "Norwegian"
173   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "NorwegianExtra.nsh" ${VLC_LANGFILE_FALLBACK}
174   !insertmacro MUI_LANGUAGE "Malay"
175   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "MalayExtra.nsh" ${VLC_LANGFILE_FALLBACK}
176   !insertmacro MUI_LANGUAGE "Korean"
177   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "KoreanExtra.nsh" ${VLC_LANGFILE_FALLBACK}
178   !insertmacro MUI_LANGUAGE "Greek"
179   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "GreekExtra.nsh" ${VLC_LANGFILE_FALLBACK}
180   !insertmacro MUI_LANGUAGE "Czech"
181   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "CzechExtra.nsh" ${VLC_LANGFILE_FALLBACK}
182   !insertmacro MUI_LANGUAGE "Bosnian"
183   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "BosnianExtra.nsh" ${VLC_LANGFILE_FALLBACK}
184   !insertmacro MUI_LANGUAGE "Arabic"
185   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "ArabicExtra.nsh" ${VLC_LANGFILE_FALLBACK}
186   !insertmacro MUI_LANGUAGE "Polish"
187   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "PolishExtra.nsh" ${VLC_LANGFILE_FALLBACK}
188   !insertmacro MUI_LANGUAGE "Romanian"
189   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "RomanianExtra.nsh" ${VLC_LANGFILE_FALLBACK}
190   !insertmacro MUI_LANGUAGE "Slovak"
191   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "SlovakExtra.nsh" ${VLC_LANGFILE_FALLBACK}
192   !insertmacro MUI_LANGUAGE "Serbian"
193   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "SerbianExtra.nsh" ${VLC_LANGFILE_FALLBACK}
194   !insertmacro MUI_LANGUAGE "Hungarian"
195   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "HungarianExtra.nsh" ${VLC_LANGFILE_FALLBACK}
196   !insertmacro MUI_LANGUAGE "Catalan"
197   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "CatalanExtra.nsh" ${VLC_LANGFILE_FALLBACK}
198   !insertmacro MUI_LANGUAGE "Bulgarian"
199   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "BulgarianExtra.nsh" ${VLC_LANGFILE_FALLBACK}
200   !insertmacro MUI_LANGUAGE "Estonian"
201   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "EstonianExtra.nsh" ${VLC_LANGFILE_FALLBACK}
202   !insertmacro MUI_LANGUAGE "Lithuanian"
203   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "LithuanianExtra.nsh" ${VLC_LANGFILE_FALLBACK}
204   !insertmacro MUI_LANGUAGE "Basque"
205   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "BasqueExtra.nsh" ${VLC_LANGFILE_FALLBACK}
206   !insertmacro MUI_LANGUAGE "Galician"
207   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "GalicianExtra.nsh" ${VLC_LANGFILE_FALLBACK}
208   !insertmacro MUI_LANGUAGE "Hebrew"
209   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "HebrewExtra.nsh" ${VLC_LANGFILE_FALLBACK}
210   !insertmacro MUI_LANGUAGE "Slovenian"
211   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "SlovenianExtra.nsh" ${VLC_LANGFILE_FALLBACK}
212   !insertmacro MUI_LANGUAGE "Afrikaans"
213   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "AfrikaansExtra.nsh" ${VLC_LANGFILE_FALLBACK}
214   !insertmacro MUI_LANGUAGE "Albanian"
215   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "AlbanianExtra.nsh" ${VLC_LANGFILE_FALLBACK}
216   !insertmacro MUI_LANGUAGE "Croatian"
217   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "CroatianExtra.nsh" ${VLC_LANGFILE_FALLBACK}
218   !insertmacro MUI_LANGUAGE "Icelandic"
219   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "IcelandicExtra.nsh" ${VLC_LANGFILE_FALLBACK}
220   !insertmacro MUI_LANGUAGE "Latvian"
221   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "LatvianExtra.nsh" ${VLC_LANGFILE_FALLBACK}
222   !insertmacro MUI_LANGUAGE "Indonesian"
223   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "IndonesianExtra.nsh" ${VLC_LANGFILE_FALLBACK}
224
225 ; Missing upstream translations:
226 ;
227 ;  !insertmacro MUI_LANGUAGE "Sinhala"
228 ;  !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "SinhalaExtra.nsh"
229 ;  !insertmacro MUI_LANGUAGE "EnglishUK"
230 ;  !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "EnglishUKExtra.nsh"
231
232 ; Upstream files broken:
233 ;  !insertmacro MUI_LANGUAGE "Khmer"
234 ;  !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "KhmerExtra.nsh"
235 ;  !insertmacro MUI_LANGUAGE "ScotsGaelic"
236 ;  !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "ScotsGaelicExtra.nsh"
237
238 ; Reserve files for solid compression
239   !insertmacro MUI_RESERVEFILE_LANGDLL
240
241 ;;;;;;;;;;;;;;;;;;;;;;;
242 ; Macro and Functions ;
243 ;;;;;;;;;;;;;;;;;;;;;;;
244
245 !include helpers\extensions.nsh
246 !include helpers\install.nsh
247 !include helpers\utils.nsh
248
249 ;;;;;;;;;;;;;;;;;;;;;;
250 ; Installer sections ;
251 ; The CORE of the    ;
252 ; installer          ;
253 ;;;;;;;;;;;;;;;;;;;;;;
254
255 ${MementoSection} "$(Name_Section01)" SEC01
256   SectionIn 1 2 3 RO
257   SetShellVarContext all
258   SetOutPath "$INSTDIR"
259
260   DetailPrint "$(Detail_CheckProcesses)"
261   Call CheckRunningProcesses
262
263   ; Remove 32 bit version first
264   !ifdef VLC_64BIT_INSTALLER
265   ${If} $32bitPath != ""
266     ; Run uninstaller
267     ClearErrors
268     ExecWait '"$32bitUninstaller" /S _?=$32bitPath'
269
270     ; If uninstall was not successfull, do not continue.
271     ; This happens for example if the user cancels the uninstaller.
272     ${If} ${Errors}
273       Goto skip_uninstall32_cleanup
274     ${EndIf}
275
276     ${If} ${FileExists} "$32bitUninstaller"
277       Delete "$32bitUninstaller"
278       RMDir "$32bitPath"
279     ${EndIf}
280   ${EndIf}
281   !endif
282
283 skip_uninstall32_cleanup:
284
285   ; Remove previous version first, if this is update
286   ${If} $ReinstallType == "1"
287     FileOpen $UninstallLog "$INSTDIR\uninstall.log" r
288     UninstallLoop:
289       ClearErrors
290       FileRead $UninstallLog $R0
291       IfErrors UninstallEnd
292       Push $R0
293       Call TrimNewLines
294       Pop $R0
295       Delete "$INSTDIR\$R0"
296       Goto UninstallLoop
297     UninstallEnd:
298     FileClose $UninstallLog
299     Delete "$INSTDIR\uninstall.log"
300     Delete "$INSTDIR\uninstall.exe"
301     Push "\"
302     Call RemoveEmptyDirs
303   ${EndIf}
304
305   !insertmacro OpenUninstallLog
306
307   ; VLC.exe, libvlc.dll
308   !insertmacro InstallFile vlc.exe
309   !insertmacro InstallFile vlc-cache-gen.exe
310
311   ; All dlls
312   !insertmacro InstallFile *.dll
313
314   ; Text files
315   !insertmacro InstallFile *.txt
316
317   ; Subfolders
318   !insertmacro InstallFolder plugins
319   !insertmacro InstallFolderOptional locale
320   !insertmacro InstallFolder hrtfs
321 @BUILD_SKINS_TRUE@   !insertmacro InstallFolder skins
322 @BUILD_LUA_TRUE@     !insertmacro InstallFolder lua
323
324   ; Generate the cache and add it to uninstall.log
325   nsExec::ExecToStack '"$INSTDIR\vlc-cache-gen.exe" $INSTDIR\plugins'
326   FindFirst $0 $1 "$INSTDIR\plugins\*.dat"
327   FileWrite $UninstallLog "plugins\$1$\r$\n"
328   FindClose $0
329
330
331   ; URLs
332   WriteIniStr "$INSTDIR\${PRODUCT_GROUP} Website.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
333   FileWrite $UninstallLog "${PRODUCT_GROUP} Website.url$\r$\n"
334   WriteIniStr "$INSTDIR\Documentation.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}/doc/"
335   FileWrite $UninstallLog "Documentation.url$\r$\n"
336   WriteIniStr "$INSTDIR\New_Skins.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}/vlc/skins.php"
337   FileWrite $UninstallLog "New_Skins.url$\r$\n"
338
339   !insertmacro CloseUninstallLog
340
341   ; Add VLC to "recommended programs" for the following extensions
342   WriteRegStr HKCR Applications\vlc.exe "" ""
343   WriteRegStr HKCR Applications\vlc.exe "FriendlyAppName" "VLC media player"
344   WriteRegStr HKCR Applications\vlc.exe\shell\Open "" "$(ContextMenuEntry_PlayWith)"
345   WriteRegStr HKCR Applications\vlc.exe\shell\Open\command "" '"$INSTDIR\vlc.exe" --started-from-file "%1"'
346   !insertmacro MacroAllExtensions RegisterExtensionMacro
347   !insertmacro MacroSkinExtensions RegisterSkinExtensionMacro
348
349   ; Add VLC to "App Paths" to run VLC from ShellExecute/ShellExecuteEx/run dialog without giving a full path
350   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\vlc.exe" "" "$INSTDIR\vlc.exe"
351   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\vlc.exe" "Path" "$INSTDIR"
352
353   ; Windows default programs Registration
354   ; Vista and above detection
355   ${If} ${AtLeastWinVista}
356     WriteRegStr HKLM "Software\RegisteredApplications" "VLC" "Software\Clients\Media\VLC\Capabilities"
357     WriteRegStr HKLM "Software\Clients\Media\VLC\Capabilities" "ApplicationName" "VLC media player"
358     WriteRegStr HKLM "Software\Clients\Media\VLC\Capabilities" "ApplicationDescription" "VLC - The video swiss knife"
359     WriteRegStr HKLM "Software\Clients\Media\VLC" "" "VLC media player"
360     WriteRegStr HKLM "Software\Clients\Media\VLC\InstallInfo" "HideIconsCommand" "$\"$INSTDIR\spad-setup.exe$\" /HideIcons /S"
361     WriteRegStr HKLM "Software\Clients\Media\VLC\InstallInfo" "ShowIconsCommand" "$\"$INSTDIR\spad-setup.exe$\" /ShowIcons /S"
362     WriteRegStr HKLM "Software\Clients\Media\VLC\InstallInfo" "ReinstallCommand" "$\"$INSTDIR\spad-setup.exe$\" /Reinstall /S"
363     WriteRegDWORD HKLM "Software\Clients\Media\VLC\InstallInfo" "IconsVisible" 0x001
364   ${EndIf}
365 ${MementoSectionEnd}
366
367 ${MementoSection} "$(Name_Section02a)" SEC02a
368   SectionIn 1 2 3
369   CreateDirectory "$SMPROGRAMS\VideoLAN"
370   CreateShortCut "$SMPROGRAMS\VideoLAN\VLC media player.lnk" \
371     "$INSTDIR\vlc.exe" ""
372   CreateShortCut "$SMPROGRAMS\VideoLAN\VLC media player skinned.lnk" \
373     "$INSTDIR\vlc.exe" "-Iskins"
374   CreateShortCut "$SMPROGRAMS\VideoLAN\Documentation.lnk" \
375     "$INSTDIR\Documentation.url"
376   CreateShortCut "$SMPROGRAMS\VideoLAN\Release Notes.lnk" \
377     "$INSTDIR\NEWS.txt" ""
378   CreateShortCut "$SMPROGRAMS\VideoLAN\${PRODUCT_GROUP} Website.lnk" \
379     "$INSTDIR\${PRODUCT_GROUP} Website.url"
380   CreateShortCut "$SMPROGRAMS\VideoLAN\VLC media player - reset preferences and cache files.lnk" \
381     "$INSTDIR\vlc.exe" "--reset-config --reset-plugins-cache vlc://quit"
382 ${MementoSectionEnd}
383
384 ${MementoSection} "$(Name_Section02b)" SEC02b
385   SectionIn 1 2 3
386   CreateShortCut "$DESKTOP\VLC media player.lnk" \
387     "$INSTDIR\vlc.exe" ""
388 ${MementoSectionEnd}
389
390 SectionGroup /e "!$(Name_Section34)"
391
392 !ifdef INSTALL_ACTIVEX
393 ${MementoSection} "$(Name_Section04)" SEC04
394   SectionIn 1 3
395
396   SetOutPath "$INSTDIR"
397   !insertmacro OpenUninstallLog
398   !insertmacro InstallFile axvlc.dll
399   !insertmacro CloseUninstallLog
400 @HAVE_WIN64_FALSE@ RegDLL "$INSTDIR\axvlc.dll"
401 @HAVE_WIN64_TRUE@  ExecWait 'regsvr32.exe /s "$INSTDIR\axvlc.dll"'
402 ${MementoSectionEnd}
403 !endif
404 SectionGroupEnd
405
406
407 ${MementoSection} "$(Name_Section05)" SEC05
408   SectionIn 1 2 3
409   WriteRegStr HKCR "AudioCD\shell\PlayWithVLC" "" "$(ContextMenuEntry_PlayWith)"
410   WriteRegStr HKCR "AudioCD\shell\PlayWithVLC\command" "" \
411     '"$INSTDIR\vlc.exe" --started-from-file cdda:///%1'
412   WriteRegStr HKCR "DVD\shell\PlayWithVLC" "" "$(ContextMenuEntry_PlayWith)"
413   WriteRegStr HKCR "DVD\shell\PlayWithVLC\command" "" \
414     '"$INSTDIR\vlc.exe" --started-from-file dvd:///%1'
415
416   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayDVDMovieOnArrival" "VLCPlayDVDMovieOnArrival" ""
417   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "Action" "$(Action_OnArrivalDVD)"
418   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "DefaultIcon" '"$INSTDIR\vlc.exe",0'
419   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "InvokeProgID" "VLC.DVDMovie"
420   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "InvokeVerb" "Open"
421   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "Provider" "VideoLAN VLC media player"
422
423   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival" "VLCPlayCDAudioOnArrival" ""
424   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "Action" "$(Action_OnArrivalAudioCD)"
425   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "DefaultIcon" '"$INSTDIR\vlc.exe",0'
426   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "InvokeProgID" "VLC.CDAudio"
427   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "InvokeVerb" "Open"
428   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "Provider" "VideoLAN VLC media player"
429
430   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayVideoCDMovieOnArrival" "VLCPlayVCDMovieOnArrival" ""
431   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayVCDMovieOnArrival" "Action" "$(Action_OnArrivalVCDMovie)"
432   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayVCDMovieOnArrival" "DefaultIcon" '"$INSTDIR\vlc.exe",0'
433   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayVCDMovieOnArrival" "InvokeProgID" "VLC.VCDMovie"
434   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayVCDMovieOnArrival" "InvokeVerb" "Open"
435   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayVCDMovieOnArrival" "Provider" "VideoLAN VLC media player"
436
437   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlaySuperVideoCDMovieOnArrival" "VLCPlaySVCDMovieOnArrival" ""
438   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlaySVCDMovieOnArrival" "Action" "$(Action_OnArrivalSVCDMovie)"
439   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlaySVCDMovieOnArrival" "DefaultIcon" '"$INSTDIR\vlc.exe",0'
440   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlaySVCDMovieOnArrival" "InvokeProgID" "VLC.SVCDMovie"
441   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlaySVCDMovieOnArrival" "InvokeVerb" "Open"
442   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlaySVCDMovieOnArrival" "Provider" "VideoLAN VLC media player"
443
444   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayDVDAudioOnArrival" "VLCPlayDVDAudioOnArrival" ""
445   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDAudioOnArrival" "Action" "$(Action_OnArrivalDVDAudio)"
446   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDAudioOnArrival" "DefaultIcon" '"$INSTDIR\vlc.exe",0'
447   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDAudioOnArrival" "InvokeProgID" "VLC.OPENFolder"
448   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDAudioOnArrival" "InvokeVerb" "Open"
449   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDAudioOnArrival" "Provider" "VideoLAN VLC media player"
450
451   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayVideoFilesOnArrival" "VLCPlayVideoFilesOnArrival" ""
452   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayVideoFilesOnArrival" "Action" "$(Action_OnArrivalVideoFiles)"
453   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayVideoFilesOnArrival" "DefaultIcon" '"$INSTDIR\vlc.exe",0'
454   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayVideoFilesOnArrival" "InvokeProgID" "VLC.OPENFolder"
455   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayVideoFilesOnArrival" "InvokeVerb" "Open"
456   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayVideoFilesOnArrival" "Provider" "VideoLAN VLC media player"
457
458   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayMusicFilesOnArrival" "VLCPlayMusicFilesOnArrival" ""
459   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayMusicFilesOnArrival" "Action" "$(Action_OnArrivalMusicFiles)"
460   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayMusicFilesOnArrival" "DefaultIcon" '"$INSTDIR\vlc.exe",0'
461   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayMusicFilesOnArrival" "InvokeProgID" "VLC.OPENFolder"
462   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayMusicFilesOnArrival" "InvokeVerb" "Open"
463   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayMusicFilesOnArrival" "Provider" "VideoLAN VLC media player"
464
465   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayBlurayOnArrival" "VLCPlayBlurayOnArrival" ""
466   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayBlurayOnArrival" "Action" "$(Action_OnArrivalBluray)"
467   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayBlurayOnArrival" "DefaultIcon" '"$INSTDIR\vlc.exe",0'
468   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayBlurayOnArrival" "InvokeProgID" "VLC.Bluray"
469   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayBlurayOnArrival" "InvokeVerb" "Open"
470   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayBlurayOnArrival" "Provider" "VideoLAN VLC media player"
471
472   WriteRegStr HKCR "VLC.DVDMovie" "" "VLC DVD Movie"
473   WriteRegStr HKCR "VLC.DVDMovie\shell" "" "Open"
474   WriteRegStr HKCR "VLC.DVDMovie\shell\Open\command" "" \
475     '"$INSTDIR\vlc.exe" --started-from-file dvd:///%1'
476   WriteRegStr HKCR "VLC.DVDMovie\DefaultIcon" "" '"$INSTDIR\vlc.exe",0'
477
478   WriteRegStr HKCR "VLC.CDAudio" "" "VLC CD Audio"
479   WriteRegStr HKCR "VLC.CDAudio\shell" "" "Open"
480   WriteRegStr HKCR "VLC.CDAudio\shell\Open\command" "" \
481     '"$INSTDIR\vlc.exe" --started-from-file cdda:///%1'
482   WriteRegStr HKCR "VLC.CDAudio\DefaultIcon" "" '"$INSTDIR\vlc.exe",0'
483
484   WriteRegStr HKCR "VLC.VCDMovie" "" "VLC VCD Movie"
485   WriteRegStr HKCR "VLC.VCDMovie\shell" "" "Open"
486   WriteRegStr HKCR "VLC.VCDMovie\shell\Open\command" "" \
487      '"$INSTDIR\vlc.exe" --started-from-file vcd:///%1'
488   WriteRegStr HKCR "VLC.VCDMovie\DefaultIcon" "" '"$INSTDIR\vlc.exe",0'
489
490   WriteRegStr HKCR "VLC.SVCDMovie" "" "VLC SVCD Movie"
491   WriteRegStr HKCR "VLC.SVCDMovie\shell" "" "Open"
492   WriteRegStr HKCR "VLC.SVCDMovie\shell\Open\command" "" \
493      '"$INSTDIR\vlc.exe" --started-from-file vcd:///%1'
494   WriteRegStr HKCR "VLC.SVCDMovie\DefaultIcon" "" '"$INSTDIR\vlc.exe",0'
495
496   WriteRegStr HKCR "VLC.OPENFolder" "" "VLC Play content"
497   WriteRegStr HKCR "VLC.OPENFolder\shell" "" "Open"
498   WriteRegStr HKCR "VLC.OPENFolder\shell\Open\command" "" \
499      '"$INSTDIR\vlc.exe" %1'
500   WriteRegStr HKCR "VLC.OPENFolder\DefaultIcon" "" '"$INSTDIR\vlc.exe",0'
501
502   WriteRegStr HKCR "VLC.Bluray" "" "VLC Bluray"
503   WriteRegStr HKCR "VLC.Bluray\shell" "" "Open"
504   WriteRegStr HKCR "VLC.Bluray\shell\Open\command" "" \
505     '"$INSTDIR\vlc.exe" --started-from-file bluray:///%1'
506   WriteRegStr HKCR "VLC.Bluray\DefaultIcon" "" '"$INSTDIR\vlc.exe",0'
507
508 ${MementoSectionEnd}
509
510
511 SectionGroup /e "!$(Name_Section06)" SEC06
512   SectionGroup "$(Name_SectionGroupAudio)"
513     !insertmacro MacroAudioExtensions AssociateExtensionSection
514   SectionGroupEnd
515   SectionGroup "$(Name_SectionGroupVideo)"
516     !insertmacro MacroVideoExtensions AssociateExtensionSection
517   SectionGroupEnd
518   SectionGroup "$(Name_SectionGroupOther)"
519     !insertmacro MacroOtherExtensions AssociateExtensionSection
520     !insertmacro MacroSkinExtensions AssociateSkinExtensionSection
521     !insertmacro MacroUnassociatedExtensions AssociateExtensionUnselectedSection
522   SectionGroupEnd
523 SectionGroupEnd
524
525 ${MementoSection} "$(Name_Section07)" SEC07
526   SectionIn 1 3
527   !insertmacro MacroAllExtensions AddContextMenu
528   !insertmacro AddContextMenuExt "Directory"
529 ${MementoSectionEnd}
530
531 ${MementoUnselectedSection} "$(Name_Section08)" SEC08
532   !insertmacro delprefs
533 ${MementoSectionEnd}
534
535 ${MementoSectionDone}
536
537 ; Installer section descriptions
538 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
539   !insertmacro MUI_DESCRIPTION_TEXT ${SEC01} "$(Desc_Section01)"
540   !insertmacro MUI_DESCRIPTION_TEXT ${SEC02a} "$(Desc_Section02a)"
541   !insertmacro MUI_DESCRIPTION_TEXT ${SEC02b} "$(Desc_Section02b)"
542 !ifdef INSTALL_MOZILLA
543   !insertmacro MUI_DESCRIPTION_TEXT ${SEC03} "$(Desc_Section03)"
544 !endif
545 !ifdef INSTALL_ACTIVEX
546   !insertmacro MUI_DESCRIPTION_TEXT ${SEC04} "$(Desc_Section04)"
547 !endif
548   !insertmacro MUI_DESCRIPTION_TEXT ${SEC05} "$(Desc_Section05)"
549   !insertmacro MUI_DESCRIPTION_TEXT ${SEC06} "$(Desc_Section06)"
550   !insertmacro MUI_DESCRIPTION_TEXT ${SEC07} "$(Desc_Section07)"
551   !insertmacro MUI_DESCRIPTION_TEXT ${SEC08} "$(Desc_Section08)"
552 !insertmacro MUI_FUNCTION_DESCRIPTION_END
553
554 ;;; Start function
555 Function .onInit
556
557 @HAVE_WIN64_TRUE@ SetRegView 64
558
559 ${MementoSectionRestore}
560
561 @HAVE_WIN64_TRUE@ !include "x64.nsh"
562 @HAVE_WIN64_TRUE@ ${Unless} ${RunningX64}
563 @HAVE_WIN64_TRUE@    MessageBox MB_OK|MB_ICONSTOP "This version of VLC only runs on 64-bit operating systems.$\nPlease get the 32-bit version and try again."
564 @HAVE_WIN64_TRUE@    Quit
565 @HAVE_WIN64_TRUE@ ${EndUnless}
566 ${If} ${AtLeastWinXP}
567     ${If} ${IsWinXP}
568     ${AndIf} ${AtMostServicePack} 1
569         Goto WinTooOld
570     ${Endif}
571 ${Else}
572     Goto WinTooOld
573 ${Endif}
574
575 ReadRegStr $INSTDIR HKLM "${PRODUCT_DIR_REGKEY}" "InstallDir"
576 StrCmp $INSTDIR "" 0 WinOk
577 StrCpy $INSTDIR "$@PROGRAMFILES@\VideoLAN\VLC"
578 Goto WinOk
579
580 WinTooOld:
581     MessageBox MB_OK|MB_ICONSTOP "This version of VLC only runs on Windows XP SP2 and newer."
582     Quit
583
584 WinOk:
585   ; /update argument
586   Call ParseCommandline
587
588   ; See if a other bitness VLC version exists
589   !ifdef VLC_64BIT_INSTALLER
590     SetRegView 32
591
592     Call ReadPreviousVersion
593
594     ${If} $PreviousVersion != ""
595       ReadRegStr $32bitUninstaller ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString"
596       ReadRegStr $32bitPath ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "InstallLocation"
597       StrCpy $PreviousVersion ""
598     ${EndIf}
599
600     SetRegView lastused
601   !endif
602
603   ; See if previous version exists
604   Call ReadPreviousVersion
605
606   ${If} $PreviousVersion == ""
607     StrCpy $PerformUpdate 0
608   ${Else}
609     Push "${VERSION}"
610     Push $PreviousVersion
611     Call VersionCompare
612
613     ${If} $PreviousVersionState != "newer"
614       StrCpy $PerformUpdate 0
615     ${EndIf}
616   ${EndIf}
617
618   !insertmacro MUI_LANGDLL_DISPLAY
619
620 FunctionEnd
621
622 ;;; Page to upgrade / downgrade or customize the installation
623 Function PageReinstall
624   ${If} $PreviousVersion == ""
625     Abort
626   ${EndIf}
627
628   ${If} $PerformUpdate == 1
629     StrCpy $ReinstallType 1
630     Abort
631   ${EndIf}
632
633   nsDialogs::Create /NOUNLOAD 1018
634   Pop $0
635
636   ${If} $PreviousVersionState == "newer"
637
638     !insertmacro MUI_HEADER_TEXT "$(Reinstall_Headline)" "$(Reinstall_HeadlineInstall)"
639     nsDialogs::CreateItem /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 0 0 100% 40 "$(Reinstall_MessageOlder)"
640     Pop $R0
641     nsDialogs::CreateItem /NOUNLOAD BUTTON ${BS_AUTORADIOBUTTON}|${BS_VCENTER}|${BS_MULTILINE}|${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${WS_GROUP}|${WS_TABSTOP} 0 10 55 100% 30 "$(Reinstall_OptionUpgrade)"
642     Pop $ReinstallUninstallBtn
643     nsDialogs::CreateItem /NOUNLOAD BUTTON ${BS_AUTORADIOBUTTON}|${BS_TOP}|${BS_MULTILINE}|${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 10 85 100% 50 "$(Reinstall_OptionAdvanced)"
644     Pop $R0
645
646     ${If} $ReinstallType == ""
647       StrCpy $ReinstallType 1
648     ${EndIf}
649
650   ${ElseIf} $PreviousVersionState == "older"
651
652     !insertmacro MUI_HEADER_TEXT "$(Reinstall_Headline)" "$(Reinstall_HeadlineInstall)"
653     nsDialogs::CreateItem /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 0 0 100% 40 "$(Reinstall_MessageNewer)"
654     Pop $R0
655     nsDialogs::CreateItem /NOUNLOAD BUTTON ${BS_AUTORADIOBUTTON}|${BS_VCENTER}|${BS_MULTILINE}|${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${WS_GROUP}|${WS_TABSTOP} 0 10 55 100% 30 "$(Reinstall_OptionDowngrade)"
656     Pop $ReinstallUninstallBtn
657     nsDialogs::CreateItem /NOUNLOAD BUTTON ${BS_AUTORADIOBUTTON}|${BS_TOP}|${BS_MULTILINE}|${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 10 85 100% 50 "$(Reinstall_OptionAdvanced)"
658     Pop $R0
659
660     ${If} $ReinstallType == ""
661       StrCpy $ReinstallType 1
662     ${EndIf}
663
664   ${ElseIf} $PreviousVersionState == "same"
665
666     !insertmacro MUI_HEADER_TEXT "$(Reinstall_Headline)" "$(Reinstall_HeadlineMaintenance)"
667     nsDialogs::CreateItem /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 0 0 100% 40 "$(Reinstall_MessageSame)"
668     Pop $R0
669     nsDialogs::CreateItem /NOUNLOAD BUTTON ${BS_AUTORADIOBUTTON}|${BS_VCENTER}|${BS_MULTILINE}|${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${WS_GROUP}|${WS_TABSTOP} 0 10 55 100% 30 "$(Reinstall_OptionComponents)"
670     Pop $R0
671     nsDialogs::CreateItem /NOUNLOAD BUTTON ${BS_AUTORADIOBUTTON}|${BS_TOP}|${BS_MULTILINE}|${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 10 85 100% 50 "$(Reinstall_OptionUninstall)"
672     Pop $ReinstallUninstallBtn
673
674     ${If} $ReinstallType == ""
675       StrCpy $ReinstallType 2
676     ${EndIf}
677
678   ${Else}
679
680     MessageBox MB_ICONSTOP "Unknown value of PreviousVersionState, aborting" /SD IDOK
681     Abort
682
683   ${EndIf}
684
685   ${If} $ReinstallType == "1"
686     SendMessage $ReinstallUninstallBtn ${BM_SETCHECK} 1 0
687   ${Else}
688     SendMessage $R0 ${BM_SETCHECK} 1 0
689   ${EndIf}
690
691   nsDialogs::Show
692
693 FunctionEnd
694
695 Function PageLeaveReinstall
696
697   SendMessage $ReinstallUninstallBtn ${BM_GETCHECK} 0 0 $R0
698   ${If} $R0 == 1
699     ; Option to uninstall old version selected
700     StrCpy $ReinstallType 1
701   ${Else}
702     ; Custom up/downgrade or add/remove/reinstall
703     StrCpy $ReinstallType 2
704   ${EndIf}
705
706   ${If} $ReinstallType == 1
707
708     ${If} $PreviousVersionState == "same"
709
710       Call RunUninstaller
711       Quit
712
713     ${EndIf}
714
715   ${EndIf}
716
717 FunctionEnd
718
719 Function RunUninstaller
720   ReadRegStr $R1 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString"
721   ${If} $R1 == ""
722     Return
723   ${EndIf}
724
725   ;Run uninstaller
726   HideWindow
727   ClearErrors
728
729   ExecWait '"$R1" _?=$INSTDIR'
730
731   IfErrors no_remove_uninstaller
732
733   IfFileExists "$INSTDIR\uninstall.exe" 0 no_remove_uninstaller
734     Delete "$R1"
735     RMDir $INSTDIR
736
737   no_remove_uninstaller:
738 FunctionEnd
739
740 Function PageSkipPre
741   ${If} $PerformUpdate == 1
742     Abort
743   ${ElseIf} $PreviousVersion != ""
744     Abort
745   ${EndIf}
746 FunctionEnd
747
748 ;;; Used during upgrade to skip most pages
749 Function PageFastUpdatePre
750   ${If} $PerformUpdate == 1
751     Abort
752   ${EndIf}
753 FunctionEnd
754
755 Function PageComponentsPre
756   ClearErrors
757   ReadRegStr $0 ${MEMENTO_REGISTRY_ROOT} `${MEMENTO_REGISTRY_KEY}` MementoSectionUsed
758   ; Backward compatibility:
759   ; Don't skip the components page until Memento was able to save the user choices.
760   IfErrors done
761
762   ${If} $ReinstallType == 1
763     Abort
764   ${EndIf}
765
766 done:
767 FunctionEnd
768
769 Function PageDirectoryPre
770   ${If} $ReinstallType != ""
771     Abort
772   ${EndIf}
773 FunctionEnd
774
775 Function .OnInstSuccess
776     ${MementoSectionSave}
777 FunctionEnd
778
779 ;; End function
780 Section -Post
781   WriteUninstaller "$INSTDIR\uninstall.exe"
782   WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "InstallDir" $INSTDIR
783   WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "Version" "${VERSION}"
784   WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\vlc.exe"
785
786   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
787     "DisplayName" "$(^Name)"
788   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
789     "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
790   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
791     "InstallLocation" "$INSTDIR"
792   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
793     "DisplayIcon" "$INSTDIR\vlc.exe"
794   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
795     "DisplayVersion" "${PRODUCT_VERSION}"
796   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
797     "URLInfoAbout" "${PRODUCT_WEB_SITE}"
798   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
799     "Publisher" "${PRODUCT_PUBLISHER}"
800   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
801     "VersionMajor"  "@VERSION_MAJOR@"
802   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
803     "VersionMinor" "@VERSION_MINOR@"
804 SectionEnd
805
806 ;;;;;;;;;;;;;;;;;;;;;;;;
807 ; Uninstaller sections ;
808 ;;;;;;;;;;;;;;;;;;;;;;;;
809
810 Section "un.$(Name_Section91)" SEC91
811   SectionIn 1 2 3 RO
812   SetShellVarContext all
813
814   !insertmacro MacroAllExtensions DeleteContextMenu
815   !insertmacro MacroAllExtensions UnRegisterExtensionSection
816   !insertmacro MacroSkinExtensions UnRegisterExtensionSection
817   !insertmacro DeleteContextMenuExt "Directory"
818
819   ;remove activex plugin
820 @HAVE_WIN64_FALSE@ UnRegDLL "$INSTDIR\axvlc.dll"
821 @HAVE_WIN64_TRUE@  ExecWait 'regsvr32.exe /s /u "$INSTDIR\axvlc.dll"'
822   Delete /REBOOTOK "$INSTDIR\axvlc.dll"
823
824   ;remove mozilla plugin
825   Push $R0
826   Push $R1
827   Push $R2
828
829   !define Index 'Line${__LINE__}'
830   StrCpy $R1 "0"
831
832   "${Index}-Loop:"
833
834     ; Check for Key
835     EnumRegKey $R0 HKLM "SOFTWARE\Mozilla" "$R1"
836     StrCmp $R0 "" "${Index}-End"
837     IntOp $R1 $R1 + 1
838     ReadRegStr $R2 HKLM "SOFTWARE\Mozilla\$R0\Extensions" "Plugins"
839     StrCmp $R2 "" "${Index}-Loop" ""
840
841     ; old files (0.8.5 and before) that may be lying around
842     Delete /REBOOTOK "$R2\npvlc.dll"
843     Delete /REBOOTOK "$R2\libvlc.dll"
844     Delete /REBOOTOK "$R2\vlcintf.xpt"
845     Goto "${Index}-Loop"
846
847   "${Index}-End:"
848   !undef Index
849   Delete /REBOOTOK "$INSTDIR\npvlc.dll"
850
851   RMDir "$SMPROGRAMS\VideoLAN"
852   RMDir /r $SMPROGRAMS\VideoLAN
853
854   FileOpen $UninstallLog "$INSTDIR\uninstall.log" r
855   UninstallLoop:
856     ClearErrors
857     FileRead $UninstallLog $R0
858     IfErrors UninstallEnd
859     Push $R0
860     Call un.TrimNewLines
861     Pop $R0
862     Delete "$INSTDIR\$R0"
863     Goto UninstallLoop
864   UninstallEnd:
865   FileClose $UninstallLog
866   Delete "$INSTDIR\uninstall.log"
867   Delete "$INSTDIR\uninstall.exe"
868   Push "\"
869   Call un.RemoveEmptyDirs
870   RMDir "$INSTDIR"
871
872   DeleteRegKey HKLM Software\VideoLAN
873
874   DeleteRegKey HKCR Applications\vlc.exe
875   DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\vlc.exe"
876   DeleteRegKey HKCR AudioCD\shell\PlayWithVLC
877   DeleteRegKey HKCR DVD\shell\PlayWithVLC
878   DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayDVDMovieOnArrival" "VLCPlayDVDMovieOnArrival"
879   DeleteRegKey HKLM Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival
880   DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival" "VLCPlayCDAudioOnArrival"
881   DeleteRegKey HKLM Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival
882   DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayVideoCDMovieOnArrival" "VLCPlayVCDMovieOnArrival"
883   DeleteRegKey HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayVCDMovieOnArrival
884   DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlaySuperVideoCDMovieOnArrival" "VLCPlaySVCDMovieOnArrival"
885   DeleteRegKey HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlaySVCDMovieOnArrival
886   DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayDVDAudioOnArrival" "VLCPlayDVDAudioOnArrival"
887   DeleteRegKey HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDAudioOnArrival
888   DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayVideoFilesOnArrival" "VLCPlayVideoFilesOnArrival"
889   DeleteRegKey HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayVideoFilesOnArrival
890   DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayMusicFilesOnArrival" "VLCPlayMusicFilesOnArrival"
891   DeleteRegKey HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayMusicFilesOnArrival
892
893   DeleteRegKey HKLM Software\Clients\Media\VLC
894   DeleteRegValue HKLM "Software\RegisteredApplications" "VLC"
895   DeleteRegKey HKCR "VLC.MediaFile"
896   DeleteRegKey HKCR "VLC.DVDMovie"
897   DeleteRegKey HKCR "VLC.CDAudio"
898   DeleteRegKey HKCR "VLC.VCDMovie"
899   DeleteRegKey HKCR "VLC.SVCDMovie"
900   DeleteRegKey HKCR "VLC.OPENFolder"
901   DeleteRegKey HKCR "VLC.Bluray"
902
903
904   DeleteRegKey HKLM \
905     "SOFTWARE\MozillaPlugins\@videolan.org/vlc,version=${VERSION}"
906
907   DeleteRegKey HKLM \
908     "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
909
910   Delete "$DESKTOP\VLC media player.lnk"
911
912   DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
913   DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
914   SetAutoClose true
915 SectionEnd
916
917 Section /o "un.$(Name_Section92)" SEC92
918   !insertmacro delprefs
919 SectionEnd
920
921 ; Uninstaller section descriptions
922 !insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
923   !insertmacro MUI_DESCRIPTION_TEXT ${SEC91} "$(Desc_Section91)"
924   !insertmacro MUI_DESCRIPTION_TEXT ${SEC92} "$(Desc_Section92)"
925 !insertmacro MUI_UNFUNCTION_DESCRIPTION_END
926
927 Function un.onInit
928
929 @HAVE_WIN64_TRUE@ SetRegView 64
930
931   !insertmacro MUI_UNGETLANGUAGE
932
933 FunctionEnd