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