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