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