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