]> git.sesse.net Git - vlc/blob - extras/package/win32/vlc.win32.nsi.in
f8971342735b0a3e4e6639afbd870f12e305e044
[vlc] / extras / package / win32 / vlc.win32.nsi.in
1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ; NSIS installer script for vlc ;
3 ; (http://nsis.sourceforge.net) ;
4 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5
6 !include "languages\declaration.nsh"
7
8 !define PRODUCT_NAME "VLC media player"
9 !define VERSION @VERSION@
10 !define PRODUCT_VERSION @VERSION@
11 !define PRODUCT_GROUP "VideoLAN"
12 !define PRODUCT_PUBLISHER "VideoLAN Team"
13 !define PRODUCT_WEB_SITE "http://www.videolan.org"
14 !define PRODUCT_DIR_REGKEY "Software\VideoLAN\VLC"
15 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
16 !define PRODUCT_UNINST_ROOT_KEY "HKLM"
17 !define PRODUCT_ID "{ea92ef52-afe4-4212-bacb-dfe9fca94cd6}"
18
19 !define MUI_LANGDLL_REGISTRY_ROOT "HKLM"
20 !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_DIR_REGKEY}"
21 !define MUI_LANGDLL_REGISTRY_VALUENAME "Language"
22
23 @FILE_LIBVLCCORE_DLL@
24 @FILE_LIBVLC_DLL@
25
26 ;;;;;;;;;;;;;;;;;;;;;;;;;
27 ; General configuration ;
28 ;;;;;;;;;;;;;;;;;;;;;;;;;
29
30 Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
31 OutFile ..\vlc-${VERSION}-win32.exe
32 InstallDir "$PROGRAMFILES\VideoLAN\VLC"
33 InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
34 !ifdef NSIS_LZMA_COMPRESS_WHOLE
35 SetCompressor lzma
36 !else
37 SetCompressor /SOLID lzma
38 !endif
39
40 ;ShowInstDetails show
41 ;ShowUnInstDetails show
42 SetOverwrite ifnewer
43 CRCCheck on
44 BrandingText "${PRODUCT_GROUP} ${PRODUCT_NAME}"
45
46 InstType $Name_InstTypeRecommended
47 InstType $Name_InstTypeMinimum
48 InstType $Name_InstTypeFull
49
50 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
51 ; NSIS Modern User Interface configuration ;
52 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
53
54 ; MUI 1.67 compatible ------
55   !include "MUI.nsh"
56
57 ; MUI Settings
58   !define MUI_ABORTWARNING
59   !define MUI_ICON "vlc.ico"
60   !define MUI_UNICON "vlc.ico"
61   !define MUI_COMPONENTSPAGE_SMALLDESC
62
63 ; Installer pages
64   ; Welcome page
65     !define MUI_WELCOMEPAGE_TITLE_3LINES
66     !insertmacro MUI_PAGE_WELCOME
67   ; License page
68     !insertmacro MUI_PAGE_LICENSE "COPYING.txt"
69   ; Components page
70     !insertmacro MUI_PAGE_COMPONENTS
71   ; Directory page
72     !insertmacro MUI_PAGE_DIRECTORY
73   ; Instfiles page
74     !insertmacro MUI_PAGE_INSTFILES
75   ; Finish page
76     !define MUI_FINISHPAGE_RUN "$INSTDIR\vlc.exe"
77     !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\README.txt"
78     !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
79     !define MUI_FINISHPAGE_LINK $Link_VisitWebsite
80     !define MUI_FINISHPAGE_LINK_LOCATION "http://www.videolan.org/vlc/"
81     !define MUI_FINISHPAGE_NOREBOOTSUPPORT
82     !insertmacro MUI_PAGE_FINISH
83
84 ; Uninstaller pages
85     !insertmacro MUI_UNPAGE_CONFIRM
86     !insertmacro MUI_UNPAGE_COMPONENTS
87     !insertmacro MUI_UNPAGE_INSTFILES
88     !insertmacro MUI_UNPAGE_FINISH
89
90 ; Language files
91   !insertmacro MUI_LANGUAGE "English" # first language is the default language
92   !insertmacro MUI_LANGUAGE "French"
93   !insertmacro MUI_LANGUAGE "German"
94   !insertmacro MUI_LANGUAGE "Spanish"
95   !insertmacro MUI_LANGUAGE "SimpChinese"
96   !insertmacro MUI_LANGUAGE "TradChinese"
97   !insertmacro MUI_LANGUAGE "Japanese"
98   !insertmacro MUI_LANGUAGE "Korean"
99   !insertmacro MUI_LANGUAGE "Italian"
100   !insertmacro MUI_LANGUAGE "Dutch"
101   !insertmacro MUI_LANGUAGE "Danish"
102   !insertmacro MUI_LANGUAGE "Swedish"
103   !insertmacro MUI_LANGUAGE "Norwegian"
104   !insertmacro MUI_LANGUAGE "Finnish"
105   !insertmacro MUI_LANGUAGE "Greek"
106   !insertmacro MUI_LANGUAGE "Russian"
107   !insertmacro MUI_LANGUAGE "Portuguese"
108   !insertmacro MUI_LANGUAGE "PortugueseBR"
109   !insertmacro MUI_LANGUAGE "Arabic"
110   !insertmacro MUI_LANGUAGE "Polish"
111   !insertmacro MUI_LANGUAGE "Romanian"
112   !insertmacro MUI_LANGUAGE "Slovak"
113   !insertmacro MUI_LANGUAGE "Czech"
114   !insertmacro MUI_LANGUAGE "Hungarian"
115   !insertmacro MUI_LANGUAGE "Catalan"
116   !insertmacro MUI_LANGUAGE "Bulgarian"
117
118 ; Reserve files for solid compression
119   !insertmacro MUI_RESERVEFILE_LANGDLL
120   !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
121
122 ; MUI end ------
123
124 ;;;;;;;;;;;;;;;;;;;;;;;
125 ; Macro and Functions ;
126 ;;;;;;;;;;;;;;;;;;;;;;;
127
128 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
129 ; 1. File type associations ;
130 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
131
132 ;; Function that register one extension for VLC
133 Function RegisterExtension
134   ; back up old value for extension $R0 (eg. ".opt")
135   ReadRegStr $1 HKCR "$R0" ""
136   StrCmp $1 "" NoBackup
137     StrCmp $1 "VLC$R0" "NoBackup"
138     WriteRegStr HKCR "$R0" "VLC.backup" $1
139 NoBackup:
140   WriteRegStr HKCR "$R0" "" "VLC$R0"
141   ReadRegStr $0 HKCR "VLC$R0" ""
142   WriteRegStr HKCR "VLC$R0" "" "VLC media file ($R0)"
143   WriteRegStr HKCR "VLC$R0\shell" "" "Play"
144   WriteRegStr HKCR "VLC$R0\shell\Play" "" $ShellAssociation_Play
145   WriteRegStr HKCR "VLC$R0\shell\Play\command" "" '"$INSTDIR\vlc.exe" --started-from-file "%1"'
146   WriteRegStr HKCR "VLC$R0\DefaultIcon" "" '"$INSTDIR\vlc.exe",0'
147
148 ;;; Vista Only part
149   ; Vista detection
150   ReadRegStr $R1 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
151   StrCpy $R2 $R1 3
152   StrCmp $R2 '6.0' ForVista ToEnd
153 ForVista:
154   WriteRegStr HKLM "Software\Clients\Media\VLC\Capabilities\FileAssociations" "$R0" "VLC$R0"
155
156 ToEnd:
157 FunctionEnd
158
159 ;; Function that removes one extension that VLC owns.
160 Function un.RegisterExtension
161   ;start of restore script
162   ReadRegStr $1 HKCR "$R0" ""
163   StrCmp $1 "VLC$R0" 0 NoOwn ; only do this if we own it
164     ; Read the old value from Backup
165     ReadRegStr $1 HKCR "$R0" "VLC.backup"
166     StrCmp $1 "" 0 Restore ; if backup="" then delete the whole key
167       DeleteRegKey HKCR "$R0"
168     Goto NoOwn
169 Restore:
170       WriteRegStr HKCR "$R0" "" $1
171       DeleteRegValue HKCR "$R0" "VLC.backup"
172 NoOwn:
173     DeleteRegKey HKCR "VLC$R0" ;Delete key with association settings
174     DeleteRegKey HKLM "Software\Clients\Media\VLC\Capabilities\FileAssociations\VLC$R0" ; for vista
175 FunctionEnd
176
177 !macro RegisterExtensionSection EXT
178   Section ${EXT}
179     SectionIn 1 3
180     Push $R0
181     StrCpy $R0 ${EXT}
182     Call RegisterExtension
183     Pop $R0
184   SectionEnd
185 !macroend
186
187 !macro UnRegisterExtensionSection EXT
188   Push $R0
189   StrCpy $R0 ${EXT}
190   Call un.RegisterExtension
191   Pop $R0
192 !macroend
193
194 !macro WriteRegStrSupportedTypes EXT
195   WriteRegStr HKCR Applications\vlc.exe\SupportedTypes ${EXT} ""
196 !macroend
197
198 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
199 ; Extension lists  Macros                    ;
200 ; Those macros calls the previous functions  ;
201 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
202
203 !macro MacroAudioExtensions _action
204   !insertmacro ${_action} ".a52"
205   !insertmacro ${_action} ".aac"
206   !insertmacro ${_action} ".ac3"
207   !insertmacro ${_action} ".dts"
208   !insertmacro ${_action} ".flac"
209   !insertmacro ${_action} ".m4a"
210   !insertmacro ${_action} ".m4p"
211   !insertmacro ${_action} ".mka"
212   !insertmacro ${_action} ".mod"
213   !insertmacro ${_action} ".mp1"
214   !insertmacro ${_action} ".mp2"
215   !insertmacro ${_action} ".mp3"
216   !insertmacro ${_action} ".oma"
217   !insertmacro ${_action} ".oga"
218   !insertmacro ${_action} ".spx"
219   !insertmacro ${_action} ".wav"
220   !insertmacro ${_action} ".wma"
221   !insertmacro ${_action} ".wv"
222   !insertmacro ${_action} ".xm"
223 !macroend
224
225 !macro MacroVideoExtensions _action
226   !insertmacro ${_action} ".asf"
227   !insertmacro ${_action} ".avi"
228   !insertmacro ${_action} ".divx"
229   !insertmacro ${_action} ".dv"
230   !insertmacro ${_action} ".flv"
231   !insertmacro ${_action} ".gxf"
232   !insertmacro ${_action} ".m1v"
233   !insertmacro ${_action} ".m2v"
234   !insertmacro ${_action} ".m2ts"
235   !insertmacro ${_action} ".m4v"
236   !insertmacro ${_action} ".mkv"
237   !insertmacro ${_action} ".mov"
238   !insertmacro ${_action} ".mp4"
239   !insertmacro ${_action} ".mpeg"
240   !insertmacro ${_action} ".mpeg1"
241   !insertmacro ${_action} ".mpeg2"
242   !insertmacro ${_action} ".mpeg4"
243   !insertmacro ${_action} ".mpg"
244   !insertmacro ${_action} ".mts"
245   !insertmacro ${_action} ".mxf"
246   !insertmacro ${_action} ".nuv"
247   !insertmacro ${_action} ".ogg"
248   !insertmacro ${_action} ".ogm"
249   !insertmacro ${_action} ".ogx"
250   !insertmacro ${_action} ".ogv"
251   !insertmacro ${_action} ".rmvb"
252   !insertmacro ${_action} ".ts"
253   !insertmacro ${_action} ".vob"
254   !insertmacro ${_action} ".wmv"
255 !macroend
256
257 !macro MacroOtherExtensions _action
258   !insertmacro ${_action} ".asx"
259   !insertmacro ${_action} ".bin"
260   !insertmacro ${_action} ".cue"
261   !insertmacro ${_action} ".m3u"
262   !insertmacro ${_action} ".pls"
263   !insertmacro ${_action} ".vlc"
264   !insertmacro ${_action} ".xspf"
265 !macroend
266
267 ; One macro to rule them all
268 !macro MacroAllExtensions _action
269   !insertmacro MacroAudioExtensions ${_action}
270   !insertmacro MacroVideoExtensions ${_action}
271   !insertmacro MacroOtherExtensions ${_action}
272 !macroend
273
274 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
275 ; 2. Context menu entries ;
276 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
277
278 ; Generic function for adding the context menu for one ext.
279 !macro AddContextMenuExt EXT
280   WriteRegStr HKCR ${EXT}\shell\PlayWithVLC "" $ContextMenuEntry_PlayWith
281   WriteRegStr HKCR ${EXT}\shell\PlayWithVLC\command "" '"$INSTDIR\vlc.exe" --started-from-file --no-playlist-enqueue "%1"'
282
283   WriteRegStr HKCR ${EXT}\shell\AddToPlaylistVLC "" $ContextMenuEntry_AddToPlaylist
284   WriteRegStr HKCR ${EXT}\shell\AddToPlaylistVLC\command "" '"$INSTDIR\vlc.exe" --started-from-file --playlist-enqueue "%1"'
285 !macroend
286
287 !macro AddContextMenu EXT
288   Push $R0
289   ReadRegStr $R0 HKCR ${EXT} ""
290   !insertmacro AddContextMenuExt $R0
291   Pop $R0
292 !macroend
293
294 !macro DeleteContextMenuExt EXT
295   DeleteRegKey HKCR ${EXT}\shell\PlayWithVLC
296   DeleteRegKey HKCR ${EXT}\shell\AddToPlaylistVLC
297 !macroend
298
299 !macro DeleteContextMenu EXT
300   Push $R0
301   ReadRegStr $R0 HKCR ${EXT} ""
302   !insertmacro DeleteContextMenuExt $R0
303   Pop $R0
304 !macroend
305
306 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
307 ; 3. Delete prefs and cache ;
308 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
309
310 !macro delprefs
311   StrCpy $0 0
312   !define Index 'Line${__LINE__}'
313   "${Index}-Loop:"
314   ; FIXME
315   ; this will loop through all the logged users and "virtual" windows users
316   ; (it looks like users are only present in HKEY_USERS when they are logged in)
317     ClearErrors
318     EnumRegKey $1 HKU "" $0
319     StrCmp $1 "" "${Index}-End"
320     IntOp $0 $0 + 1
321     ReadRegStr $2 HKU "$1\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" AppData
322     StrCmp $2 "" "${Index}-Loop"
323     RMDir /r "$2\vlc"
324     Goto "${Index}-Loop"
325   "${Index}-End:"
326   !undef Index
327 !macroend
328
329 ;;;;;;;;;;;;;;;
330 ; 4. Logging  ;
331 ;;;;;;;;;;;;;;;
332 Var UninstallLog
333 !macro OpenUninstallLog
334   FileOpen $UninstallLog "$INSTDIR\uninstall.log" a
335   FileSeek $UninstallLog 0 END
336 !macroend
337
338 !macro CloseUninstallLog
339   FileClose $UninstallLog
340   SetFileAttributes "$INSTDIR\uninstall.log" HIDDEN
341 !macroend
342
343 ;;;;;;;;;;;;;;;;;;;;
344 ; 5. Installations ;
345 ;;;;;;;;;;;;;;;;;;;;
346 !macro InstallFile FILEREGEX
347   File "${FILEREGEX}"
348   !define Index 'Line${__LINE__}'
349   FindFirst $0 $1 "$INSTDIR\${FILEREGEX}"
350   StrCmp $0 "" "${Index}-End"
351   "${Index}-Loop:"
352     StrCmp $1 "" "${Index}-End"
353     FileWrite $UninstallLog "$1$\r$\n"
354     FindNext $0 $1
355     Goto "${Index}-Loop"
356   "${Index}-End:"
357   !undef Index
358 !macroend
359
360 !macro InstallFolder FOLDER
361   File /r "${FOLDER}"
362   Push "${FOLDER}"
363   Call InstallFolderInternal
364 !macroend
365
366 Function InstallFolderInternal
367   Pop $9
368   !define Index 'Line${__LINE__}'
369   FindFirst $0 $1 "$INSTDIR\$9\*"
370   StrCmp $0 "" "${Index}-End"
371   "${Index}-Loop:"
372     StrCmp $1 "" "${Index}-End"
373     StrCmp $1 "." "${Index}-Next"
374     StrCmp $1 ".." "${Index}-Next"
375     IfFileExists "$9\$1\*" 0 "${Index}-Write"
376       Push $0
377       Push $9
378       Push "$9\$1"
379       Call InstallFolderInternal
380       Pop $9
381       Pop $0
382       Goto "${Index}-Next"
383     "${Index}-Write:"
384     FileWrite $UninstallLog "$9\$1$\r$\n"
385     "${Index}-Next:"
386     FindNext $0 $1
387     Goto "${Index}-Loop"
388   "${Index}-End:"
389   !undef Index
390 FunctionEnd
391 ;;; End of Macros
392
393
394 ;;;;;;;;;;;;;;;;;;;;;;
395 ; Installer sections ;
396 ; The CORE of the    ;
397 ; installer          ;
398 ;;;;;;;;;;;;;;;;;;;;;;
399   
400 Section $Name_Section01 SEC01
401   SectionIn 1 2 3 RO
402   SetShellVarContext all
403   SetOutPath "$INSTDIR"
404
405   !insertmacro OpenUninstallLog
406
407   ; VLC.exe, libvlc.dll
408   !insertmacro InstallFile vlc.exe
409   !insertmacro InstallFile vlc.exe.manifest
410
411   ; All dlls
412   !insertmacro InstallFile *.dll
413
414   ; Text files
415   !insertmacro InstallFile *.txt
416
417   ; Subfolders
418   !insertmacro InstallFolder plugins
419   !insertmacro InstallFolder locale
420   !insertmacro InstallFolder osdmenu
421   !insertmacro InstallFolder skins
422   !insertmacro InstallFolder http
423   !insertmacro InstallFolder lua
424
425   ; URLs
426   WriteIniStr "$INSTDIR\${PRODUCT_GROUP} Website.url" "InternetShortcut" "URL" \
427     "${PRODUCT_WEB_SITE}"
428   FileWrite $UninstallLog "${PRODUCT_GROUP} Website.url$\r$\n"
429   WriteIniStr "$INSTDIR\Documentation.url" "InternetShortcut" "URL" \
430     "${PRODUCT_WEB_SITE}/doc/"
431   FileWrite $UninstallLog "Documentation.url$\r$\n"
432   WriteIniStr "$INSTDIR\New_Skins.url" "InternetShortcut" "URL" \
433     "${PRODUCT_WEB_SITE}/vlc/skins.php"
434   FileWrite $UninstallLog "New_Skins.url$\r$\n"
435
436   !insertmacro CloseUninstallLog
437
438   ; Add VLC to "recomended programs" for the following extensions
439   WriteRegStr HKCR Applications\vlc.exe "" ""
440   WriteRegStr HKCR Applications\vlc.exe "FriendlyAppName" "VLC media player"
441   WriteRegStr HKCR Applications\vlc.exe\shell\Play "" $ContextMenuEntry_PlayWith
442   WriteRegStr HKCR Applications\vlc.exe\shell\Play\command "" \
443     '"$INSTDIR\vlc.exe" --started-from-file "%1"'
444   !insertmacro MacroAllExtensions WriteRegStrSupportedTypes
445
446 ; Vista Registration
447   ; Vista detection
448   ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
449   StrCpy $R1 $R0 3
450   StrCmp $R1 '6.0' lbl_vista lbl_done
451
452   lbl_vista:
453   WriteRegStr HKLM "Software\RegisteredApplications" "VLC" "Software\Clients\Media\VLC\Capabilities"
454   WriteRegStr HKLM "Software\Clients\Media\VLC\Capabilities" "ApplicationName" "VLC media player"
455   WriteRegStr HKLM "Software\Clients\Media\VLC\Capabilities" "ApplicationDescription" "VLC - The video swiss knife"
456
457   lbl_done:
458 SectionEnd
459
460 Section $Name_Section02a SEC02a
461   SectionIn 1 2 3
462   CreateDirectory "$SMPROGRAMS\VideoLAN"
463   CreateDirectory "$SMPROGRAMS\VideoLAN\Quick Settings"
464   CreateDirectory "$SMPROGRAMS\VideoLAN\Quick Settings\Audio"
465   CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Audio\Set Audio mode to DirectX (default).lnk" \
466     "$INSTDIR\vlc.exe" "--aout aout_directx --save-config vlc://quit"
467   CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Audio\Set Audio mode to Waveout.lnk" \
468     "$INSTDIR\vlc.exe" "--aout waveout --save-config vlc://quit"
469   CreateDirectory "$SMPROGRAMS\VideoLAN\Quick Settings\Interface"
470   CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Interface\Set Main Interface to Skinnable.lnk" \
471     "$INSTDIR\vlc.exe" "-I skins --save-config vlc://quit"
472   CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Interface\Set Main Interface to Qt (default).lnk" \
473     "$INSTDIR\vlc.exe" "-I qt --save-config vlc://quit"
474   CreateDirectory "$SMPROGRAMS\VideoLAN\Quick Settings\Video"
475   ; FIXME add detection for Vista. Direct3D will be default there, for all others it's DirectX
476   CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to Direct3D.lnk" \
477     "$INSTDIR\vlc.exe" "--vout direct3d --overlay --directx-hw-yuv --save-config vlc://quit"
478   CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to Direct3D (no hardware acceleration).lnk" \
479     "$INSTDIR\vlc.exe" "--vout direct3d --overlay --no-directx-hw-yuv --save-config vlc://quit"
480   CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to DirectX.lnk" \
481     "$INSTDIR\vlc.exe" "--vout directx --overlay --directx-hw-yuv --save-config vlc://quit"
482   CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to DirectX (no hardware acceleration).lnk" \
483     "$INSTDIR\vlc.exe" "--vout directx --no-overlay --no-directx-hw-yuv --save-config vlc://quit"
484   CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to DirectX (no video overlay).lnk" \
485     "$INSTDIR\vlc.exe" "--vout directx --no-overlay --directx-hw-yuv --save-config vlc://quit"
486   CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to OpenGL.lnk" \
487     "$INSTDIR\vlc.exe" "--vout opengl --overlay --save-config vlc://quit"
488   CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Reset VLC media player preferences and cache files.lnk" \
489     "$INSTDIR\vlc.exe" "--reset-config --reset-plugins-cache vlc://quit"
490   CreateShortCut "$SMPROGRAMS\VideoLAN\Documentation.lnk" \
491     "$INSTDIR\Documentation.url"
492   CreateShortCut "$SMPROGRAMS\VideoLAN\Release Notes.lnk" \
493     "$INSTDIR\NEWS.txt" ""
494   CreateShortCut "$SMPROGRAMS\VideoLAN\${PRODUCT_GROUP} Website.lnk" \
495     "$INSTDIR\${PRODUCT_GROUP} Website.url"
496   CreateShortCut "$SMPROGRAMS\VideoLAN\VLC media player.lnk" \
497     "$INSTDIR\vlc.exe" ""
498 SectionEnd
499
500 Section $Name_Section02b SEC02b
501   SectionIn 1 2 3
502   CreateShortCut "$DESKTOP\VLC media player.lnk" \
503     "$INSTDIR\vlc.exe" ""
504 SectionEnd
505
506 Section /o $Name_Section03 SEC03
507   SectionIn 3
508
509   SetOutPath "$INSTDIR"
510   !insertmacro OpenUninstallLog
511   !insertmacro InstallFile mozilla\npvlc.dll
512   !insertmacro InstallFile mozilla\npvlc.dll.manifest
513   !insertmacro CloseUninstallLog
514
515   !define Moz "SOFTWARE\MozillaPlugins\@videolan.org/vlc,version=${VERSION}"
516   WriteRegStr HKLM ${Moz} "Description" "VLC Multimedia Plugin"
517   WriteRegStr HKLM ${Moz} "Path" "$INSTDIR\npvlc.dll"
518   WriteRegStr HKLM ${Moz} "Product" "VLC media player"
519   WriteRegStr HKLM ${Moz} "Vendor" "VideoLAN"
520   WriteRegStr HKLM ${Moz} "Version" "${VERSION}"
521
522  ; for very old version of mozilla, these lines may be needed
523  ;Push $R0
524  ;Push $R1
525  ;Push $R2
526
527  ;!define Index 'Line${__LINE__}'
528  ;StrCpy $R1 "0"
529
530  ;"${Index}-Loop:"
531
532  ;  ; Check for Key
533  ;  EnumRegKey $R0 HKLM "SOFTWARE\Mozilla" "$R1"
534  ;  StrCmp $R0 "" "${Index}-End"
535  ;  IntOp $R1 $R1 + 1
536  ;  ReadRegStr $R2 HKLM "SOFTWARE\Mozilla\$R0\Extensions" "Plugins"
537  ;  StrCmp $R2 "" "${Index}-Loop" ""
538
539  ;  CopyFiles "$INSTDIR\npvlc.dll" "$R2"
540  ;  !ifdef LIBVLC_DLL
541  ;  CopyFiles ${LIBVLC_DLL} "$R2"
542  ;  !endif
543  ;  !ifdef LIBVLC_CONTROL_DLL
544  ;  CopyFiles ${LIBVLC_CONTROL_DLL} "$R2"
545  ;  !endif
546  ;  Goto "${Index}-Loop"
547
548  ;"${Index}-End:"
549  ;!undef Index
550
551 SectionEnd
552
553 Section $Name_Section04 SEC04
554   SectionIn 3
555   SetOutPath "$INSTDIR"
556   !insertmacro OpenUninstallLog
557   !insertmacro InstallFile activex\axvlc.dll
558   !insertmacro InstallFile activex\axvlc.dll.manifest
559   !insertmacro CloseUninstallLog
560   RegDLL "$INSTDIR\axvlc.dll"
561 SectionEnd
562
563
564 Section $Name_Section05 SEC05
565   SectionIn 1 2 3
566   WriteRegStr HKCR "AudioCD\shell\PlayWithVLC" "" $ContextMenuEntry_PlayWith
567   WriteRegStr HKCR "AudioCD\shell\PlayWithVLC\command" "" \
568     '"$INSTDIR\vlc.exe" --started-from-file cdda://%1'
569   WriteRegStr HKCR "DVD\shell\PlayWithVLC" "" $ContextMenuEntry_PlayWith
570   WriteRegStr HKCR "DVD\shell\PlayWithVLC\command" "" \
571     '"$INSTDIR\vlc.exe" --started-from-file dvd://%1'
572
573   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayDVDMovieOnArrival" "VLCPlayDVDMovieOnArrival" ""
574   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "Action" $Action_OnArrivalDVD
575   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "DefaultIcon" '"$INSTDIR\vlc.exe",0'
576   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "InvokeProgID" "VLC.DVDMovie"
577   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "InvokeVerb" "play"
578   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "Provider" "VideoLAN VLC media player"
579
580   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival" "VLCPlayCDAudioOnArrival" ""
581   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "Action" $Action_OnArrivalAudioCD
582   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "DefaultIcon" '"$INSTDIR\vlc.exe",0'
583   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "InvokeProgID" "VLC.CDAudio"
584   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "InvokeVerb" "play"
585   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "Provider" "VideoLAN VLC media player"
586   WriteRegStr HKCR "VLC.DVDMovie" "" "VLC DVD Movie"
587   WriteRegStr HKCR "VLC.DVDMovie\shell" "" "Play"
588   WriteRegStr HKCR "VLC.DVDMovie\shell\Play\command" "" \
589     '"$INSTDIR\vlc.exe" --started-from-file dvd://%1'
590   WriteRegStr HKCR "VLC.DVDMovie\DefaultIcon" "" '"$INSTDIR\vlc.exe",0'
591   WriteRegStr HKCR "VLC.CDAudio" "" "VLC CD Audio"
592   WriteRegStr HKCR "VLC.CDAudio\shell" "" "Play"
593   WriteRegStr HKCR "VLC.CDAudio\shell\Play\command" "" \
594     '"$INSTDIR\vlc.exe" --started-from-file cdda://%1'
595   WriteRegStr HKCR "VLC.CDAudio\DefaultIcon" "" '"$INSTDIR\vlc.exe",0'
596
597 SectionEnd
598
599
600 SectionGroup /e !$Name_Section06 SEC06
601   SectionGroup $Name_SectionGroupAudio
602     !insertmacro MacroAudioExtensions RegisterExtensionSection
603   SectionGroupEnd
604   SectionGroup $Name_SectionGroupVideo
605     !insertmacro MacroVideoExtensions RegisterExtensionSection
606   SectionGroupEnd
607   SectionGroup $Name_SectionGroupOther
608     !insertmacro MacroOtherExtensions RegisterExtensionSection
609   SectionGroupEnd
610 SectionGroupEnd
611
612 Section $Name_Section07 SEC07
613   SectionIn 1 3
614   !insertmacro MacroAllExtensions AddContextMenu
615   !insertmacro AddContextMenuExt "Directory"
616 SectionEnd
617
618 Section $Name_Section08 SEC08
619   !insertmacro delprefs
620 SectionEnd
621
622 ; Installer section descriptions
623 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
624   !insertmacro MUI_DESCRIPTION_TEXT ${SEC01} $Desc_Section01
625   !insertmacro MUI_DESCRIPTION_TEXT ${SEC02a} $Desc_Section02a
626   !insertmacro MUI_DESCRIPTION_TEXT ${SEC02b} $Desc_Section02b
627   !insertmacro MUI_DESCRIPTION_TEXT ${SEC03} $Desc_Section03
628   !insertmacro MUI_DESCRIPTION_TEXT ${SEC04} $Desc_Section04
629   !insertmacro MUI_DESCRIPTION_TEXT ${SEC05} $Desc_Section05
630   !insertmacro MUI_DESCRIPTION_TEXT ${SEC06} $Desc_Section06
631   !insertmacro MUI_DESCRIPTION_TEXT ${SEC07} $Desc_Section07
632   !insertmacro MUI_DESCRIPTION_TEXT ${SEC08} $Desc_Section08
633 !insertmacro MUI_FUNCTION_DESCRIPTION_END
634
635 ;;; Start function
636 Function .onInit
637   !insertmacro MUI_LANGDLL_DISPLAY
638
639   !include "languages\english.nsh"
640   StrCmp $LANGUAGE ${LANG_FRENCH} French 0
641   StrCmp $LANGUAGE ${LANG_ITALIAN} Italian 0
642   StrCmp $LANGUAGE ${LANG_HUNGARIAN} Hungarian 0
643   StrCmp $LANGUAGE ${LANG_ROMANIAN} Romanian 0
644   StrCmp $LANGUAGE ${LANG_CATALAN} Catalan 0
645   StrCmp $LANGUAGE ${LANG_BULGARIAN} Bulgarian 0
646   StrCmp $LANGUAGE ${LANG_SLOVAK} Slovak 0
647   StrCmp $LANGUAGE ${LANG_POLISH} Polish 0
648   StrCmp $LANGUAGE ${LANG_DUTCH} Dutch 0
649   StrCmp $LANGUAGE ${LANG_SIMPCHINESE} SChinese 0
650   StrCmp $LANGUAGE ${LANG_FINNISH} Finnish 0
651   StrCmp $LANGUAGE ${LANG_PORTUGUESEBR} Brazilian EndLanguageCmp
652   French:
653   !include "languages\french.nsh"
654   Goto EndLanguageCmp
655   Italian:
656   !include "languages\italian.nsh"
657   Goto EndLanguageCmp
658   Hungarian:
659   !include "languages\hungarian.nsh"
660   Goto EndLanguageCmp
661   Romanian:
662   !include "languages\romanian.nsh"
663   Goto EndLanguageCmp
664   Catalan:
665   !include "languages\catalan.nsh"
666   Goto EndLanguageCmp
667   Bulgarian:
668   !include "languages\bulgarian.nsh"
669   Goto EndLanguageCmp
670   Slovak:
671   !include "languages\slovak.nsh"
672   Goto EndLanguageCmp
673   Polish:
674   !include "languages\polish.nsh"
675   Goto EndLanguageCmp
676   Dutch:
677   !include "languages\dutch.nsh"
678   Goto EndLanguageCmp
679   Schinese:
680   !include "languages\schinese.nsh"
681   Goto EndLanguageCmp
682   Finnish:
683   !include "languages\finnish.nsh"
684   Goto EndLanguageCmp
685   Brazilian:
686   !include "languages\brazilian_portuguese.nsh"
687   EndLanguageCmp:
688
689   ReadRegStr $R0  ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
690   "UninstallString"
691   StrCmp $R0 "" done
692
693   MessageBox MB_YESNO|MB_ICONEXCLAMATION $Message_AlreadyInstalled IDNO done
694
695   ;Run the uninstaller
696   ;uninst:
697     ClearErrors
698     ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
699   done:
700
701 FunctionEnd
702
703 ;; End function
704 Section -Post
705   WriteUninstaller "$INSTDIR\uninstall.exe"
706   WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "InstallDir" $INSTDIR
707   WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "Version" "${VERSION}"
708   WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\vlc.exe"
709
710   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
711     "DisplayName" "$(^Name)"
712   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
713     "UninstallString" "$INSTDIR\uninstall.exe"
714   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
715     "DisplayIcon" "$INSTDIR\vlc.exe"
716   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
717     "DisplayVersion" "${PRODUCT_VERSION}"
718   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
719     "URLInfoAbout" "${PRODUCT_WEB_SITE}"
720   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
721     "Publisher" "${PRODUCT_PUBLISHER}"
722 SectionEnd
723
724 ;;;;;;;;;;;;;;;;;;;;;;;;
725 ; Uninstaller sections ;
726 ;;;;;;;;;;;;;;;;;;;;;;;;
727
728 ; TrimNewlines (copied from NSIS documentation)
729 ; input, top of stack  (e.g. whatever$\r$\n)
730 ; output, top of stack (replaces, with e.g. whatever)
731 ; modifies no other variables.
732
733 Function un.TrimNewlines
734  Exch $R0
735  Push $R1
736  Push $R2
737  StrCpy $R1 0
738
739  loop:
740    IntOp $R1 $R1 - 1
741    StrCpy $R2 $R0 1 $R1
742    StrCmp $R2 "$\r" loop
743    StrCmp $R2 "$\n" loop
744    IntOp $R1 $R1 + 1
745    IntCmp $R1 0 no_trim_needed
746    StrCpy $R0 $R0 $R1
747
748  no_trim_needed:
749    Pop $R2
750    Pop $R1
751    Exch $R0
752 FunctionEnd
753
754 Function un.RemoveEmptyDirs
755   Pop $9
756   !define Index 'Line${__LINE__}'
757   FindFirst $0 $1 "$INSTDIR$9*"
758   StrCmp $0 "" "${Index}-End"
759   "${Index}-Loop:"
760     StrCmp $1 "" "${Index}-End"
761     StrCmp $1 "." "${Index}-Next"
762     StrCmp $1 ".." "${Index}-Next"
763       Push $0
764       Push $1
765       Push $9
766       Push "$9$1\"
767       Call un.RemoveEmptyDirs
768       Pop $9
769       Pop $1
770       Pop $0
771     "${Index}-Remove:"
772     RMDir "$INSTDIR$9$1"
773     "${Index}-Next:"
774     FindNext $0 $1
775     Goto "${Index}-Loop"
776   "${Index}-End:"
777   FindClose $0
778   !undef Index
779 FunctionEnd
780
781 Section "un.$Name_Section91" SEC91
782   SectionIn 1 2 3 RO
783   SetShellVarContext all
784
785   !insertmacro MacroAllExtensions DeleteContextMenu
786   !insertmacro MacroAllExtensions UnRegisterExtensionSection
787   !insertmacro DeleteContextMenuExt "Directory"
788
789   ;remove activex plugin
790   UnRegDLL "$INSTDIR\axvlc.dll"
791   Delete /REBOOTOK "$INSTDIR\axvlc.dll"
792   Delete /REBOOTOK "$INSTDIR\axvlc.dll.manifest"
793
794   ;remove mozilla plugin
795   Push $R0
796   Push $R1
797   Push $R2
798
799   !define Index 'Line${__LINE__}'
800   StrCpy $R1 "0"
801
802   "${Index}-Loop:"
803
804     ; Check for Key
805     EnumRegKey $R0 HKLM "SOFTWARE\Mozilla" "$R1"
806     StrCmp $R0 "" "${Index}-End"
807     IntOp $R1 $R1 + 1
808     ReadRegStr $R2 HKLM "SOFTWARE\Mozilla\$R0\Extensions" "Plugins"
809     StrCmp $R2 "" "${Index}-Loop" ""
810
811     ; old files (0.8.5 and before) that may be lying around
812     Delete /REBOOTOK "$R2\npvlc.dll"
813     Delete /REBOOTOK "$R2\libvlc.dll"
814     Delete /REBOOTOK "$R2\vlcintf.xpt"
815     Goto "${Index}-Loop"
816
817   "${Index}-End:"
818   !undef Index
819   Delete /REBOOTOK "$INSTDIR\npvlc.dll"
820   Delete /REBOOTOK "$INSTDIR\npvlc.dll.manifest"
821
822   RMDir "$SMPROGRAMS\VideoLAN"
823   RMDir /r $SMPROGRAMS\VideoLAN
824
825   FileOpen $UninstallLog "$INSTDIR\uninstall.log" r
826   UninstallLoop:
827     ClearErrors
828     FileRead $UninstallLog $R0
829     IfErrors UninstallEnd
830     Push $R0
831     Call un.TrimNewLines
832     Pop $R0
833     Delete "$INSTDIR\$R0"
834     Goto UninstallLoop
835   UninstallEnd:
836   FileClose $UninstallLog
837   Delete "$INSTDIR\uninstall.log"
838   Delete "$INSTDIR\uninstall.exe"
839   Push "\"
840   Call un.RemoveEmptyDirs
841   RMDir "$INSTDIR"
842
843   DeleteRegKey HKLM Software\VideoLAN
844
845   DeleteRegKey HKCR Applications\vlc.exe
846   DeleteRegKey HKCR AudioCD\shell\PlayWithVLC
847   DeleteRegKey HKCR DVD\shell\PlayWithVLC
848   DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayDVDMovieOnArrival" "VLCPlayDVDMovieOnArrival"
849   DeleteRegKey HKLM Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival
850   DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival" "VLCPlayCDAudioOnArrival"
851   DeleteRegKey HKLM Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival
852   DeleteRegKey HKLM Software\Clients\Media\VLC
853   DeleteRegKey HKCR "VLC.MediaFile"
854
855   DeleteRegKey HKLM \
856     "SOFTWARE\MozillaPlugins\@videolan.org/vlc,version=${VERSION}"
857
858   DeleteRegKey HKLM \
859     "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
860
861   Delete "$DESKTOP\VLC media player.lnk"
862
863   DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
864   DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
865   SetAutoClose true
866 SectionEnd
867
868 Section /o "un.$Name_Section92" SEC92
869   !insertmacro delprefs
870 SectionEnd
871
872 ; Uninstaller section descriptions
873 !insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
874   !insertmacro MUI_DESCRIPTION_TEXT ${SEC91} $Desc_Section91
875   !insertmacro MUI_DESCRIPTION_TEXT ${SEC92} $Desc_Section92
876 !insertmacro MUI_UNFUNCTION_DESCRIPTION_END
877
878 ;Function un.onUninstSuccess
879 ;  HideWindow
880 ;  MessageBox MB_ICONINFORMATION|MB_OK \
881 ;    "$(^Name) was successfully removed from your computer."
882 ;FunctionEnd
883
884 Function un.onInit
885   !insertmacro MUI_UNGETLANGUAGE
886   
887   !include "languages\english.nsh"
888   StrCmp $LANGUAGE ${LANG_FRENCH} French 0
889   StrCmp $LANGUAGE ${LANG_ITALIAN} Italian 0
890   StrCmp $LANGUAGE ${LANG_HUNGARIAN} Hungarian 0
891   StrCmp $LANGUAGE ${LANG_ROMANIAN} Romanian 0
892   StrCmp $LANGUAGE ${LANG_CATALAN} Catalan 0
893   StrCmp $LANGUAGE ${LANG_BULGARIAN} Bulgarian 0
894   StrCmp $LANGUAGE ${LANG_SLOVAK} Slovak 0
895   StrCmp $LANGUAGE ${LANG_POLISH} Polish 0
896   StrCmp $LANGUAGE ${LANG_DUTCH} Dutch 0
897   StrCmp $LANGUAGE ${LANG_SIMPCHINESE} SChinese 0
898   StrCmp $LANGUAGE ${LANG_FINNISH} Finnish 0
899   StrCmp $LANGUAGE ${LANG_PORTUGUESEBR} Brazilian EndLanguageCmp
900   French:
901   !include "languages\french.nsh"
902   Goto EndLanguageCmp
903   Italian:
904   !include "languages\italian.nsh"
905   Goto EndLanguageCmp
906   Hungarian:
907   !include "languages\hungarian.nsh"
908   Goto EndLanguageCmp
909   Romanian:
910   !include "languages\romanian.nsh"
911   Goto EndLanguageCmp
912   Catalan:
913   !include "languages\catalan.nsh"
914   Goto EndLanguageCmp
915   Bulgarian:
916   !include "languages\bulgarian.nsh"
917   Goto EndLanguageCmp
918   Slovak:
919   !include "languages\slovak.nsh"
920   Goto EndLanguageCmp
921   Polish:
922   !include "languages\polish.nsh"
923   Goto EndLanguageCmp
924   Dutch:
925   !include "languages\dutch.nsh"
926   Goto EndLanguageCmp
927   Schinese:
928   !include "languages\schinese.nsh"
929   Goto EndLanguageCmp
930   Finnish:
931   !include "languages\finnish.nsh"
932   Goto EndLanguageCmp
933   Brazilian:
934   !include "languages\brazilian_portuguese.nsh"
935   EndLanguageCmp:
936   
937 FunctionEnd