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