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