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