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