VLC media player: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
(→‎The Script: the nsi.in file was moved)
 
(2 intermediate revisions by 2 users not shown)
Line 3: Line 3:


== The Script ==
== The Script ==
http://trac.videolan.org/vlc/browser/extras/package/win32/vlc.win32.nsi.in
http://git.videolan.org/?p=vlc.git;a=blob;f=extras/package/win32/NSIS/vlc.win32.nsi.in;hb=HEAD ([http://git.videolan.org/?p=vlc.git;a=blob_plain;f=extras/package/win32/NSIS/vlc.win32.nsi.in;hb=HEAD raw])
<highlight-nsis>
<highlight-nsis>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; NSIS installer script for vlc ;  
; NSIS installer script for vlc ;
; (http://nsis.sourceforge.net) ;  
; (http://nsis.sourceforge.net) ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


!include "languages\declaration.nsh"
!include "languages\declaration.nsh"  


!define PRODUCT_NAME "VLC media player"
!define PRODUCT_NAME "VLC media player"  
!define VERSION @VERSION@
!define VERSION @VERSION@  
!define PRODUCT_VERSION @VERSION@
!define PRODUCT_VERSION @VERSION@  
!define PRODUCT_GROUP "VideoLAN"
!define PRODUCT_GROUP "VideoLAN"  
!define PRODUCT_PUBLISHER "VideoLAN Team"
!define PRODUCT_PUBLISHER "VideoLAN Team"  
!define PRODUCT_WEB_SITE "http://www.videolan.org"
!define PRODUCT_WEB_SITE "http://www.videolan.org"  
!define PRODUCT_DIR_REGKEY "Software\VideoLAN\VLC"
!define PRODUCT_DIR_REGKEY "Software\VideoLAN\VLC"  
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"  
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"  
!define PRODUCT_ID "{ea92ef52-afe4-4212-bacb-dfe9fca94cd6}"
!define PRODUCT_ID "{ea92ef52-afe4-4212-bacb-dfe9fca94cd6}"  


!define MUI_LANGDLL_REGISTRY_ROOT "HKLM"
!define MUI_LANGDLL_REGISTRY_ROOT "HKLM"  
!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_DIR_REGKEY}"
!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_DIR_REGKEY}"  
!define MUI_LANGDLL_REGISTRY_VALUENAME "Language"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Language"  


@FILE_LIBVLCCORE_DLL@
@FILE_LIBVLCCORE_DLL@  
@FILE_LIBVLC_DLL@
@FILE_LIBVLC_DLL@  


;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;  
; General configuration ;
; General configuration ;  
;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;  


Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"  
OutFile ..\vlc-${VERSION}-win32.exe
OutFile ..\vlc-${VERSION}-win32.exe  
InstallDir "$PROGRAMFILES\VideoLAN\VLC"
InstallDir "$PROGRAMFILES\VideoLAN\VLC"  
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""  
!ifdef NSIS_LZMA_COMPRESS_WHOLE
!ifdef NSIS_LZMA_COMPRESS_WHOLE  
SetCompressor lzma
SetCompressor lzma  
!else
!else  
SetCompressor /SOLID lzma
SetCompressor /SOLID lzma  
!endif
!endif  


;ShowInstDetails show
;ShowInstDetails show  
;ShowUnInstDetails show
;ShowUnInstDetails show  
SetOverwrite ifnewer
SetOverwrite ifnewer  
CRCCheck on
CRCCheck on  
BrandingText "${PRODUCT_GROUP} ${PRODUCT_NAME}"
BrandingText "${PRODUCT_GROUP} ${PRODUCT_NAME}"  


InstType $Name_InstTypeRecommended
InstType $Name_InstTypeRecommended  
InstType $Name_InstTypeMinimum
InstType $Name_InstTypeMinimum  
InstType $Name_InstTypeFull
InstType $Name_InstTypeFull  


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  
; NSIS Modern User Interface configuration ;
; NSIS Modern User Interface configuration ;  
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  


; MUI 1.67 compatible ------
; MUI 1.67 compatible ------  
   !include "MUI.nsh"
   !include "MUI.nsh"  


; MUI Settings
; MUI Settings  
   !define MUI_ABORTWARNING
   !define MUI_ABORTWARNING  
   !define MUI_ICON "vlc.ico"
   !define MUI_ICON "vlc48x48.ico"  
   !define MUI_UNICON "vlc.ico"
   !define MUI_UNICON "vlc48x48.ico"  
   !define MUI_COMPONENTSPAGE_SMALLDESC
   !define MUI_COMPONENTSPAGE_SMALLDESC  


; Installer pages
; Installer pages  
   ; Welcome page
   ; Welcome page  
     !define MUI_WELCOMEPAGE_TITLE_3LINES
     !define MUI_WELCOMEPAGE_TITLE_3LINES  
     !insertmacro MUI_PAGE_WELCOME
     !insertmacro MUI_PAGE_WELCOME  
   ; License page
   ; License page  
     !insertmacro MUI_PAGE_LICENSE "COPYING.txt"
     !insertmacro MUI_PAGE_LICENSE "COPYING.txt"  
   ; Components page
   ; Components page  
     !insertmacro MUI_PAGE_COMPONENTS
     !insertmacro MUI_PAGE_COMPONENTS  
   ; Directory page
   ; Directory page  
     !insertmacro MUI_PAGE_DIRECTORY
     !insertmacro MUI_PAGE_DIRECTORY  
   ; Instfiles page
   ; Instfiles page  
     !insertmacro MUI_PAGE_INSTFILES
     !insertmacro MUI_PAGE_INSTFILES  
   ; Finish page
   ; Finish page  
     !define MUI_FINISHPAGE_RUN "$INSTDIR\vlc.exe"
     !define MUI_FINISHPAGE_RUN "$INSTDIR\vlc.exe"  
     !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\README.txt"
     !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\README.txt"  
     !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
     !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED  
     !define MUI_FINISHPAGE_LINK $Link_VisitWebsite
     !define MUI_FINISHPAGE_LINK $Link_VisitWebsite  
     !define MUI_FINISHPAGE_LINK_LOCATION "http://www.videolan.org/vlc/"
     !define MUI_FINISHPAGE_LINK_LOCATION "http://www.videolan.org/vlc/"  
     !define MUI_FINISHPAGE_NOREBOOTSUPPORT
     !define MUI_FINISHPAGE_NOREBOOTSUPPORT  
     !insertmacro MUI_PAGE_FINISH
     !insertmacro MUI_PAGE_FINISH  


; Uninstaller pages
; Uninstaller pages  
     !insertmacro MUI_UNPAGE_CONFIRM
     !insertmacro MUI_UNPAGE_CONFIRM  
     !insertmacro MUI_UNPAGE_COMPONENTS
     !insertmacro MUI_UNPAGE_COMPONENTS  
     !insertmacro MUI_UNPAGE_INSTFILES
     !insertmacro MUI_UNPAGE_INSTFILES  
     !insertmacro MUI_UNPAGE_FINISH
     !insertmacro MUI_UNPAGE_FINISH  


; Language files
; Language files  
   !insertmacro MUI_LANGUAGE "English" # first language is the default language
   !insertmacro MUI_LANGUAGE "English" # first language is the default language  
   !insertmacro MUI_LANGUAGE "French"
   !insertmacro MUI_LANGUAGE "French"  
   !insertmacro MUI_LANGUAGE "German"
   !insertmacro MUI_LANGUAGE "German"  
   !insertmacro MUI_LANGUAGE "Spanish"
   !insertmacro MUI_LANGUAGE "Spanish"  
   !insertmacro MUI_LANGUAGE "SimpChinese"
   !insertmacro MUI_LANGUAGE "SimpChinese"  
   !insertmacro MUI_LANGUAGE "TradChinese"
   !insertmacro MUI_LANGUAGE "TradChinese"  
   !insertmacro MUI_LANGUAGE "Japanese"
   !insertmacro MUI_LANGUAGE "Japanese"  
   !insertmacro MUI_LANGUAGE "Korean"
   !insertmacro MUI_LANGUAGE "Korean"  
   !insertmacro MUI_LANGUAGE "Italian"
   !insertmacro MUI_LANGUAGE "Italian"  
   !insertmacro MUI_LANGUAGE "Dutch"
   !insertmacro MUI_LANGUAGE "Dutch"  
   !insertmacro MUI_LANGUAGE "Danish"
   !insertmacro MUI_LANGUAGE "Danish"  
   !insertmacro MUI_LANGUAGE "Swedish"
   !insertmacro MUI_LANGUAGE "Swedish"  
   !insertmacro MUI_LANGUAGE "Norwegian"
   !insertmacro MUI_LANGUAGE "Norwegian"  
   !insertmacro MUI_LANGUAGE "Finnish"
   !insertmacro MUI_LANGUAGE "Finnish"  
   !insertmacro MUI_LANGUAGE "Greek"
   !insertmacro MUI_LANGUAGE "Greek"  
   !insertmacro MUI_LANGUAGE "Russian"
   !insertmacro MUI_LANGUAGE "Russian"  
   !insertmacro MUI_LANGUAGE "Portuguese"
   !insertmacro MUI_LANGUAGE "Portuguese"  
  !insertmacro MUI_LANGUAGE "PortugueseBR"
   !insertmacro MUI_LANGUAGE "Arabic"  
   !insertmacro MUI_LANGUAGE "Arabic"
   !insertmacro MUI_LANGUAGE "Polish"  
   !insertmacro MUI_LANGUAGE "Polish"
   !insertmacro MUI_LANGUAGE "Romanian"  
   !insertmacro MUI_LANGUAGE "Romanian"
   !insertmacro MUI_LANGUAGE "Slovak"  
   !insertmacro MUI_LANGUAGE "Slovak"
   !insertmacro MUI_LANGUAGE "Czech"  
   !insertmacro MUI_LANGUAGE "Czech"
  !insertmacro MUI_LANGUAGE "Hungarian"
  !insertmacro MUI_LANGUAGE "Catalan"
  !insertmacro MUI_LANGUAGE "Bulgarian"


; Reserve files for solid compression
; Reserve files for solid compression  
   !insertmacro MUI_RESERVEFILE_LANGDLL
   !insertmacro MUI_RESERVEFILE_LANGDLL  
   !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
   !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS  


; MUI end ------
; MUI end ------  


;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;  
; Macro and Functions ;
; Macro and Functions ;  
;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;  


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  
; 1. File type associations ;
; 1. File type associations ;  
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  


;; Function that register one extension for VLC
;; Function that register one extension for VLC  
Function RegisterExtension
Function RegisterExtension  
   ; back up old value for extension $R0 (eg. ".opt")
   ; back up old value for extension $R0 (eg. ".opt")  
   ReadRegStr $1 HKCR "$R0" ""
   ReadRegStr $1 HKCR "$R0" ""  
   StrCmp $1 "" NoBackup
   StrCmp $1 "" NoBackup  
     StrCmp $1 "VLC$R0" "NoBackup"
     StrCmp $1 "VLC$R0" "NoBackup"  
     WriteRegStr HKCR "$R0" "VLC.backup" $1
     WriteRegStr HKCR "$R0" "VLC.backup" $1  
NoBackup:
NoBackup:  
   WriteRegStr HKCR "$R0" "" "VLC$R0"
   WriteRegStr HKCR "$R0" "" "VLC$R0"  
   ReadRegStr $0 HKCR "VLC$R0" ""
   ReadRegStr $0 HKCR "VLC$R0" ""  
   WriteRegStr HKCR "VLC$R0" "" "VLC media file ($R0)"
   WriteRegStr HKCR "VLC$R0" "" "VLC media file ($R0)"  
   WriteRegStr HKCR "VLC$R0\shell" "" "Play"
   WriteRegStr HKCR "VLC$R0\shell" "" "Play"  
   WriteRegStr HKCR "VLC$R0\shell\Play" "" $ShellAssociation_Play
   WriteRegStr HKCR "VLC$R0\shell\Play" "" $ShellAssociation_Play  
   WriteRegStr HKCR "VLC$R0\shell\Play\command" "" '"$INSTDIR\vlc.exe" --started-from-file "%1"'
   WriteRegStr HKCR "VLC$R0\shell\Play\command" "" '"$INSTDIR\vlc.exe" --started-from-file "%1"'  
   WriteRegStr HKCR "VLC$R0\DefaultIcon" "" '"$INSTDIR\vlc.exe",0'
   WriteRegStr HKCR "VLC$R0\DefaultIcon" "" '"$INSTDIR\vlc.exe",0'  


;;; Vista Only part
;;; Vista Only part  
   ; Vista detection
   ; Vista detection  
   ReadRegStr $R1 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
   ReadRegStr $R1 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion  
   StrCpy $R2 $R1 3
   StrCpy $R2 $R1 3  
   StrCmp $R2 '6.0' ForVista ToEnd
   StrCmp $R2 '6.0' ForVista ToEnd  
ForVista:
ForVista:  
   WriteRegStr HKLM "Software\Clients\Media\VLC\Capabilities\FileAssociations" "$R0" "VLC$R0"
   WriteRegStr HKLM "Software\Clients\Media\VLC\Capabilities\FileAssociations" "$R0" "VLC$R0"  


ToEnd:
ToEnd:  
FunctionEnd
FunctionEnd  


;; Function that removes one extension that VLC owns.
;; Function that removes one extension that VLC owns.  
Function un.RegisterExtension
Function un.RegisterExtension  
   ;start of restore script
   ;start of restore script  
   ReadRegStr $1 HKCR "$R0" ""
   ReadRegStr $1 HKCR "$R0" ""  
   StrCmp $1 "VLC$R0" 0 NoOwn ; only do this if we own it
   StrCmp $1 "VLC$R0" 0 NoOwn ; only do this if we own it  
     ; Read the old value from Backup
     ; Read the old value from Backup  
     ReadRegStr $1 HKCR "$R0" "VLC.backup"
     ReadRegStr $1 HKCR "$R0" "VLC.backup"  
     StrCmp $1 "" 0 Restore ; if backup="" then delete the whole key
     StrCmp $1 "" 0 Restore ; if backup="" then delete the whole key  
       DeleteRegKey HKCR "$R0"
       DeleteRegKey HKCR "$R0"  
     Goto NoOwn
     Goto NoOwn  
Restore:
Restore:  
       WriteRegStr HKCR "$R0" "" $1
       WriteRegStr HKCR "$R0" "" $1  
       DeleteRegValue HKCR "$R0" "VLC.backup"
       DeleteRegValue HKCR "$R0" "VLC.backup"  
NoOwn:
NoOwn:  
     DeleteRegKey HKCR "VLC$R0" ;Delete key with association settings
     DeleteRegKey HKCR "VLC$R0" ;Delete key with association settings  
     DeleteRegKey HKLM "Software\Clients\Media\VLC\Capabilities\FileAssociations\VLC$R0" ; for vista
     DeleteRegKey HKLM "Software\Clients\Media\VLC\Capabilities\FileAssociations\VLC$R0" ; for vista  
FunctionEnd
FunctionEnd  


!macro RegisterExtensionSection EXT
!macro RegisterExtensionSection EXT  
   Section ${EXT}
   Section ${EXT}  
     SectionIn 1 3
     SectionIn 1 3  
     Push $R0
     Push $R0  
     StrCpy $R0 ${EXT}
     StrCpy $R0 ${EXT}  
     Call RegisterExtension
     Call RegisterExtension  
     Pop $R0
     Pop $R0  
   SectionEnd
   SectionEnd  
!macroend
!macroend  


!macro UnRegisterExtensionSection EXT
!macro UnRegisterExtensionSection EXT  
   Push $R0
   Push $R0  
   StrCpy $R0 ${EXT}
   StrCpy $R0 ${EXT}  
   Call un.RegisterExtension
   Call un.RegisterExtension  
   Pop $R0
   Pop $R0  
!macroend
!macroend  


!macro WriteRegStrSupportedTypes EXT
!macro WriteRegStrSupportedTypes EXT  
   WriteRegStr HKCR Applications\vlc.exe\SupportedTypes ${EXT} ""
   WriteRegStr HKCR Applications\vlc.exe\SupportedTypes ${EXT} ""  
!macroend
!macroend  


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  
; Extension lists  Macros                    ;
; Extension lists  Macros                    ;  
; Those macros calls the previous functions  ;
; Those macros calls the previous functions  ;  
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  


!macro MacroAudioExtensions _action
!macro MacroAudioExtensions _action  
   !insertmacro ${_action} ".a52"
   !insertmacro ${_action} ".a52"  
   !insertmacro ${_action} ".aac"
   !insertmacro ${_action} ".aac"  
   !insertmacro ${_action} ".ac3"
   !insertmacro ${_action} ".ac3"  
   !insertmacro ${_action} ".dts"
   !insertmacro ${_action} ".dts"  
   !insertmacro ${_action} ".flac"
   !insertmacro ${_action} ".flac"  
   !insertmacro ${_action} ".m4a"
   !insertmacro ${_action} ".m4a"  
   !insertmacro ${_action} ".m4p"
   !insertmacro ${_action} ".m4p"  
   !insertmacro ${_action} ".mka"
   !insertmacro ${_action} ".mka"  
   !insertmacro ${_action} ".mod"
   !insertmacro ${_action} ".mod"  
   !insertmacro ${_action} ".mp1"
   !insertmacro ${_action} ".mp1"  
   !insertmacro ${_action} ".mp2"
   !insertmacro ${_action} ".mp2"  
   !insertmacro ${_action} ".mp3"
   !insertmacro ${_action} ".mp3"  
   !insertmacro ${_action} ".oma"
   !insertmacro ${_action} ".oma"  
   !insertmacro ${_action} ".oga"
   !insertmacro ${_action} ".ogg"  
   !insertmacro ${_action} ".spx"
   !insertmacro ${_action} ".spx"  
   !insertmacro ${_action} ".wav"
   !insertmacro ${_action} ".wav"  
   !insertmacro ${_action} ".wma"
   !insertmacro ${_action} ".wma"  
   !insertmacro ${_action} ".wv"
   !insertmacro ${_action} ".wma"  
   !insertmacro ${_action} ".xm"
   !insertmacro ${_action} ".xm"  
!macroend
!macroend  


!macro MacroVideoExtensions _action
!macro MacroVideoExtensions _action  
   !insertmacro ${_action} ".asf"
   !insertmacro ${_action} ".asf"  
   !insertmacro ${_action} ".avi"
   !insertmacro ${_action} ".avi"  
   !insertmacro ${_action} ".divx"
   !insertmacro ${_action} ".divx"  
   !insertmacro ${_action} ".dv"
   !insertmacro ${_action} ".dv"  
   !insertmacro ${_action} ".flv"
   !insertmacro ${_action} ".flv"  
   !insertmacro ${_action} ".gxf"
   !insertmacro ${_action} ".gxf"  
   !insertmacro ${_action} ".m1v"
   !insertmacro ${_action} ".m1v"  
   !insertmacro ${_action} ".m2v"
   !insertmacro ${_action} ".m2v"  
   !insertmacro ${_action} ".m2ts"
   !insertmacro ${_action} ".m2ts"  
   !insertmacro ${_action} ".m4v"
   !insertmacro ${_action} ".m4v"  
   !insertmacro ${_action} ".mkv"
   !insertmacro ${_action} ".mkv"  
   !insertmacro ${_action} ".mov"
   !insertmacro ${_action} ".mov"  
   !insertmacro ${_action} ".mp4"
   !insertmacro ${_action} ".mp4"  
   !insertmacro ${_action} ".mpeg"
   !insertmacro ${_action} ".mpeg"  
   !insertmacro ${_action} ".mpeg1"
   !insertmacro ${_action} ".mpeg1"  
   !insertmacro ${_action} ".mpeg2"
   !insertmacro ${_action} ".mpeg2"  
   !insertmacro ${_action} ".mpeg4"
   !insertmacro ${_action} ".mpeg4"  
   !insertmacro ${_action} ".mpg"
   !insertmacro ${_action} ".mpg"  
   !insertmacro ${_action} ".mts"
   !insertmacro ${_action} ".mts"  
   !insertmacro ${_action} ".mxf"
   !insertmacro ${_action} ".mxf"  
  !insertmacro ${_action} ".nuv"
   !insertmacro ${_action} ".ogm"  
  !insertmacro ${_action} ".ogg"
   !insertmacro ${_action} ".ps"  
   !insertmacro ${_action} ".ogm"
   !insertmacro ${_action} ".ts"  
   !insertmacro ${_action} ".ogx"
   !insertmacro ${_action} ".vob"  
  !insertmacro ${_action} ".ogv"
   !insertmacro ${_action} ".wmv"  
  !insertmacro ${_action} ".rmvb"
!macroend  
   !insertmacro ${_action} ".ts"
   !insertmacro ${_action} ".vob"
   !insertmacro ${_action} ".wmv"
!macroend


!macro MacroOtherExtensions _action
!macro MacroOtherExtensions _action  
   !insertmacro ${_action} ".asx"
   !insertmacro ${_action} ".asx"  
   !insertmacro ${_action} ".bin"
   !insertmacro ${_action} ".bin"  
   !insertmacro ${_action} ".cue"
   !insertmacro ${_action} ".cue"  
   !insertmacro ${_action} ".m3u"
   !insertmacro ${_action} ".m3u"  
   !insertmacro ${_action} ".pls"
   !insertmacro ${_action} ".pls"  
   !insertmacro ${_action} ".vlc"
   !insertmacro ${_action} ".vlc"  
  !insertmacro ${_action} ".xspf"
!macroend  
!macroend


; One macro to rule them all
; One macro to rule them all  
!macro MacroAllExtensions _action
!macro MacroAllExtensions _action  
   !insertmacro MacroAudioExtensions ${_action}
   !insertmacro MacroAudioExtensions ${_action}  
   !insertmacro MacroVideoExtensions ${_action}
   !insertmacro MacroVideoExtensions ${_action}  
   !insertmacro MacroOtherExtensions ${_action}
   !insertmacro MacroOtherExtensions ${_action}  
!macroend
!macroend  


;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;  
; 2. Context menu entries ;
; 2. Context menu entries ;  
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;  


; Generic function for adding the context menu for one ext.
; Generic function for adding the context menu for one ext.  
!macro AddContextMenuExt EXT
!macro AddContextMenuExt EXT  
   WriteRegStr HKCR ${EXT}\shell\PlayWithVLC "" $ContextMenuEntry_PlayWith
   WriteRegStr HKCR ${EXT}\shell\PlayWithVLC "" $ContextMenuEntry_PlayWith  
   WriteRegStr HKCR ${EXT}\shell\PlayWithVLC\command "" '"$INSTDIR\vlc.exe" --started-from-file --no-playlist-enqueue "%1"'
   WriteRegStr HKCR ${EXT}\shell\PlayWithVLC\command "" '$INSTDIR\vlc.exe --started-from-file --no-playlist-enqueue "%1"'  


   WriteRegStr HKCR ${EXT}\shell\AddToPlaylistVLC "" $ContextMenuEntry_AddToPlaylist
   WriteRegStr HKCR ${EXT}\shell\AddToPlaylistVLC "" $ContextMenuEntry_AddToPlaylist  
   WriteRegStr HKCR ${EXT}\shell\AddToPlaylistVLC\command "" '"$INSTDIR\vlc.exe" --started-from-file --playlist-enqueue "%1"'
   WriteRegStr HKCR ${EXT}\shell\AddToPlaylistVLC\command "" '$INSTDIR\vlc.exe --started-from-file --playlist-enqueue "%1"'  
!macroend
!macroend  


!macro AddContextMenu EXT
!macro AddContextMenu EXT  
   Push $R0
   Push $R0  
   ReadRegStr $R0 HKCR ${EXT} ""
   ReadRegStr $R0 HKCR ${EXT} ""  
   !insertmacro AddContextMenuExt $R0
   !insertmacro AddContextMenuExt $R0  
   Pop $R0
   Pop $R0  
!macroend
!macroend  


!macro DeleteContextMenuExt EXT
!macro DeleteContextMenuExt EXT  
   DeleteRegKey HKCR ${EXT}\shell\PlayWithVLC
   DeleteRegKey HKCR ${EXT}\shell\PlayWithVLC  
   DeleteRegKey HKCR ${EXT}\shell\AddToPlaylistVLC
   DeleteRegKey HKCR ${EXT}\shell\AddToPlaylistVLC  
!macroend
!macroend  


!macro DeleteContextMenu EXT
!macro DeleteContextMenu EXT  
   Push $R0
   Push $R0  
   ReadRegStr $R0 HKCR ${EXT} ""
   ReadRegStr $R0 HKCR ${EXT} ""  
   !insertmacro DeleteContextMenuExt $R0
   !insertmacro DeleteContextMenuExt $R0  
   Pop $R0
   Pop $R0  
!macroend
!macroend  


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  
; 3. Delete prefs and cache ;
; 3. Delete prefs and cache ;  
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  


!macro delprefs
!macro delprefs  
   StrCpy $0 0
   StrCpy $0 0  
   !define Index 'Line${__LINE__}'
   !define Index 'Line${__LINE__}'  
   "${Index}-Loop:"
   "${Index}-Loop:"  
   ; FIXME
   ; FIXME  
   ; this will loop through all the logged users and "virtual" windows users
   ; this will loop through all the logged users and "virtual" windows users  
   ; (it looks like users are only present in HKEY_USERS when they are logged in)
   ; (it looks like users are only present in HKEY_USERS when they are logged in)  
     ClearErrors
     ClearErrors  
     EnumRegKey $1 HKU "" $0
     EnumRegKey $1 HKU "" $0  
     StrCmp $1 "" "${Index}-End"
     StrCmp $1 "" "${Index}-End"  
     IntOp $0 $0 + 1
     IntOp $0 $0 + 1  
     ReadRegStr $2 HKU "$1\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" AppData
     ReadRegStr $2 HKU "$1\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" AppData  
     StrCmp $2 "" "${Index}-Loop"
     StrCmp $2 "" "${Index}-Loop"  
     RMDir /r "$2\vlc"
     RMDir /r "$2\vlc"  
     Goto "${Index}-Loop"
     Goto "${Index}-Loop"  
   "${Index}-End:"
   "${Index}-End:"  
   !undef Index
   !undef Index  
!macroend
!macroend  


;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;  
; 4. Logging  ;
; 4. Logging  ;  
;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;  
Var UninstallLog
Var UninstallLog  
!macro OpenUninstallLog
!macro OpenUninstallLog  
   FileOpen $UninstallLog "$INSTDIR\uninstall.log" a
   FileOpen $UninstallLog "$INSTDIR\uninstall.log" a  
   FileSeek $UninstallLog 0 END
   FileSeek $UninstallLog 0 END  
!macroend
!macroend  


!macro CloseUninstallLog
!macro CloseUninstallLog  
   FileClose $UninstallLog
   FileClose $UninstallLog  
   SetFileAttributes "$INSTDIR\uninstall.log" HIDDEN
   SetFileAttributes "$INSTDIR\uninstall.log" HIDDEN  
!macroend
!macroend  


;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;  
; 5. Installations ;
; 5. Installations ;  
;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;  
!macro InstallFile FILEREGEX
!macro InstallFile FILEREGEX  
   File "${FILEREGEX}"
   File "${FILEREGEX}"  
   !define Index 'Line${__LINE__}'
   !define Index 'Line${__LINE__}'  
   FindFirst $0 $1 "$INSTDIR\${FILEREGEX}"
   FindFirst $0 $1 "$INSTDIR\${FILEREGEX}"  
   StrCmp $0 "" "${Index}-End"
   StrCmp $0 "" "${Index}-End"  
   "${Index}-Loop:"
   "${Index}-Loop:"  
     StrCmp $1 "" "${Index}-End"
     StrCmp $1 "" "${Index}-End"  
     FileWrite $UninstallLog "$1$\r$\n"
     FileWrite $UninstallLog "$1$\r$\n"  
     FindNext $0 $1
     FindNext $0 $1  
     Goto "${Index}-Loop"
     Goto "${Index}-Loop"  
   "${Index}-End:"
   "${Index}-End:"  
   !undef Index
   !undef Index  
!macroend
!macroend  


!macro InstallFolder FOLDER
!macro InstallFolder FOLDER  
   File /r "${FOLDER}"
   File /r "${FOLDER}"  
   Push "${FOLDER}"
   Push "${FOLDER}"  
   Call InstallFolderInternal
   Call InstallFolderInternal  
!macroend
!macroend  


Function InstallFolderInternal
Function InstallFolderInternal  
   Pop $9
   Pop $9  
   !define Index 'Line${__LINE__}'
   !define Index 'Line${__LINE__}'  
   FindFirst $0 $1 "$INSTDIR\$9\*"
   FindFirst $0 $1 "$INSTDIR\$9\*"  
   StrCmp $0 "" "${Index}-End"
   StrCmp $0 "" "${Index}-End"  
   "${Index}-Loop:"
   "${Index}-Loop:"  
     StrCmp $1 "" "${Index}-End"
     StrCmp $1 "" "${Index}-End"  
     StrCmp $1 "." "${Index}-Next"
     StrCmp $1 "." "${Index}-Next"  
     StrCmp $1 ".." "${Index}-Next"
     StrCmp $1 ".." "${Index}-Next"  
     IfFileExists "$9\$1\*" 0 "${Index}-Write"
     IfFileExists "$9\$1\*" 0 "${Index}-Write"  
       Push $0
       Push $0  
       Push $9
       Push $9  
       Push "$9\$1"
       Push "$9\$1"  
       Call InstallFolderInternal
       Call InstallFolderInternal  
       Pop $9
       Pop $9  
       Pop $0
       Pop $0  
       Goto "${Index}-Next"
       Goto "${Index}-Next"  
     "${Index}-Write:"
     "${Index}-Write:"  
     FileWrite $UninstallLog "$9\$1$\r$\n"
     FileWrite $UninstallLog "$9\$1$\r$\n"  
     "${Index}-Next:"
     "${Index}-Next:"  
     FindNext $0 $1
     FindNext $0 $1  
     Goto "${Index}-Loop"
     Goto "${Index}-Loop"  
   "${Index}-End:"
   "${Index}-End:"  
   !undef Index
   !undef Index  
FunctionEnd
FunctionEnd  
;;; End of Macros
;;; End of Macros  




;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;  
; Installer sections ;
; Installer sections ;  
; The CORE of the    ;
; The CORE of the    ;  
; installer          ;
; installer          ;  
;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;  
 
 
Section $Name_Section01 SEC01
Section $Name_Section01 SEC01  
   SectionIn 1 2 3 RO
   SectionIn 1 2 3 RO  
   SetShellVarContext all
   SetShellVarContext all  
   SetOutPath "$INSTDIR"
   SetOutPath "$INSTDIR"  


   !insertmacro OpenUninstallLog
   !insertmacro OpenUninstallLog  


   ; VLC.exe, libvlc.dll
   ; VLC.exe, libvlc.dll  
   !insertmacro InstallFile vlc.exe
   !insertmacro InstallFile vlc.exe  
   !insertmacro InstallFile vlc.exe.manifest
   !insertmacro InstallFile vlc.exe.manifest  
  !ifdef LIBVLCCORE_DLL
      !insertmacro InstallFile ${LIBVLCCORE_DLL}
  !endif
  !ifdef LIBVLC_DLL
      !insertmacro InstallFile ${LIBVLC_DLL}
  !endif


   ; All dlls
   ; Text files
   !insertmacro InstallFile *.dll
   !insertmacro InstallFile *.txt


   ; Text files
   ; Subfolders
   !insertmacro InstallFile *.txt
  !insertmacro InstallFolder plugins
  !insertmacro InstallFolder locale
  !insertmacro InstallFolder osdmenu
  !insertmacro InstallFolder skins
  !insertmacro InstallFolder http
   !insertmacro InstallFolder lua


   ; Subfolders
   ; URLs
   !insertmacro InstallFolder plugins
   WriteIniStr "$INSTDIR\${PRODUCT_GROUP} Website.url" "InternetShortcut" "URL" \
   !insertmacro InstallFolder locale
    "${PRODUCT_WEB_SITE}"
   !insertmacro InstallFolder osdmenu
   FileWrite $UninstallLog "${PRODUCT_GROUP} Website.url$\r$\n"
   !insertmacro InstallFolder skins
   WriteIniStr "$INSTDIR\Documentation.url" "InternetShortcut" "URL" \
   !insertmacro InstallFolder http
    "${PRODUCT_WEB_SITE}/doc/"
   !insertmacro InstallFolder lua
   FileWrite $UninstallLog "Documentation.url$\r$\n"
   WriteIniStr "$INSTDIR\New_Skins.url" "InternetShortcut" "URL" \
    "${PRODUCT_WEB_SITE}/vlc/skins.php"
   FileWrite $UninstallLog "New_Skins.url$\r$\n"


  ; URLs
   !insertmacro CloseUninstallLog
  WriteIniStr "$INSTDIR\${PRODUCT_GROUP} Website.url" "InternetShortcut" "URL" \
    "${PRODUCT_WEB_SITE}"
  FileWrite $UninstallLog "${PRODUCT_GROUP} Website.url$\r$\n"
  WriteIniStr "$INSTDIR\Documentation.url" "InternetShortcut" "URL" \
    "${PRODUCT_WEB_SITE}/doc/"
  FileWrite $UninstallLog "Documentation.url$\r$\n"
  WriteIniStr "$INSTDIR\New_Skins.url" "InternetShortcut" "URL" \
    "${PRODUCT_WEB_SITE}/vlc/skins.php"
   FileWrite $UninstallLog "New_Skins.url$\r$\n"


   !insertmacro CloseUninstallLog
  ; Add VLC to "recomended programs" for the following extensions
  WriteRegStr HKCR Applications\vlc.exe "" ""
  WriteRegStr HKCR Applications\vlc.exe "FriendlyAppName" "VLC media player"
  WriteRegStr HKCR Applications\vlc.exe\shell\Play "" $ContextMenuEntry_PlayWith
  WriteRegStr HKCR Applications\vlc.exe\shell\Play\command "" \
    '$INSTDIR\vlc.exe --started-from-file "%1"'
   !insertmacro MacroAllExtensions WriteRegStrSupportedTypes


  ; Add VLC to "recomended programs" for the following extensions
; Vista Registration
   WriteRegStr HKCR Applications\vlc.exe "" ""
   ; Vista detection
   WriteRegStr HKCR Applications\vlc.exe "FriendlyAppName" "VLC media player"
   ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
  WriteRegStr HKCR Applications\vlc.exe\shell\Play "" $ContextMenuEntry_PlayWith
   StrCpy $R1 $R0 3
   WriteRegStr HKCR Applications\vlc.exe\shell\Play\command "" \
  StrCmp $R1 '6.0' lbl_vista lbl_done
    '"$INSTDIR\vlc.exe" --started-from-file "%1"'
  !insertmacro MacroAllExtensions WriteRegStrSupportedTypes


; Vista Registration
   lbl_vista:
   ; Vista detection
   WriteRegStr HKLM "Software\RegisteredApplications" "VLC" "Software\Clients\Media\VLC\Capabilities"  
   ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
   WriteRegStr HKLM "Software\Clients\Media\VLC\Capabilities" "ApplicationName" "VLC media player"
   StrCpy $R1 $R0 3
   WriteRegStr HKLM "Software\Clients\Media\VLC\Capabilities" "ApplicationDescription" "VLC - The video swiss knife"
   StrCmp $R1 '6.0' lbl_vista lbl_done


  lbl_vista:
   lbl_done:
  WriteRegStr HKLM "Software\RegisteredApplications" "VLC" "Software\Clients\Media\VLC\Capabilities"
SectionEnd
   WriteRegStr HKLM "Software\Clients\Media\VLC\Capabilities" "ApplicationName" "VLC media player"
  WriteRegStr HKLM "Software\Clients\Media\VLC\Capabilities" "ApplicationDescription" "VLC - The video swiss knife"


   lbl_done:
Section $Name_Section02a SEC02a
SectionEnd
   SectionIn 1 2 3
  CreateDirectory "$SMPROGRAMS\VideoLAN"
  CreateDirectory "$SMPROGRAMS\VideoLAN\Quick Settings"
  CreateDirectory "$SMPROGRAMS\VideoLAN\Quick Settings\Audio"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Audio\Set Audio mode to DirectX (default).lnk" \
    "$INSTDIR\vlc.exe" "--aout aout_directx --save-config vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Audio\Set Audio mode to Waveout.lnk" \
    "$INSTDIR\vlc.exe" "--aout waveout --save-config vlc://quit"
  CreateDirectory "$SMPROGRAMS\VideoLAN\Quick Settings\Interface"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Interface\Set Main Interface to Skinnable.lnk" \
    "$INSTDIR\vlc.exe" "-I skins --save-config vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Interface\Set Main Interface to Qt (default).lnk" \
    "$INSTDIR\vlc.exe" "-I qt --save-config vlc://quit"
  CreateDirectory "$SMPROGRAMS\VideoLAN\Quick Settings\Video"
  ; FIXME add detection for Vista. Direct3D will be default there, for all others it's DirectX
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to Direct3D.lnk" \
    "$INSTDIR\vlc.exe" "--vout direct3d --overlay --directx-hw-yuv --save-config vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to Direct3D (no hardware acceleration).lnk" \
    "$INSTDIR\vlc.exe" "--vout direct3d --overlay --no-directx-hw-yuv --save-config vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to DirectX.lnk" \
    "$INSTDIR\vlc.exe" "--vout directx --overlay --directx-hw-yuv --save-config vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to DirectX (no hardware acceleration).lnk" \
    "$INSTDIR\vlc.exe" "--vout directx --no-overlay --no-directx-hw-yuv --save-config vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to DirectX (no video overlay).lnk" \
    "$INSTDIR\vlc.exe" "--vout directx --no-overlay --directx-hw-yuv --save-config vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to OpenGL.lnk" \
    "$INSTDIR\vlc.exe" "--vout opengl --overlay --save-config vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Reset VLC media player preferences and cache files.lnk" \
    "$INSTDIR\vlc.exe" "--reset-config --reset-plugins-cache vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Documentation.lnk" \
    "$INSTDIR\Documentation.url"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Release Notes.lnk" \
    "$INSTDIR\NEWS.txt" ""
  CreateShortCut "$SMPROGRAMS\VideoLAN\${PRODUCT_GROUP} Website.lnk" \
    "$INSTDIR\${PRODUCT_GROUP} Website.url"
  CreateShortCut "$SMPROGRAMS\VideoLAN\VLC media player.lnk" \
    "$INSTDIR\vlc.exe" ""
SectionEnd  


Section $Name_Section02a SEC02a
Section $Name_Section02b SEC02b
   SectionIn 1 2 3
   SectionIn 1 2 3  
  CreateDirectory "$SMPROGRAMS\VideoLAN"
   CreateShortCut "$DESKTOP\VLC media player.lnk" \  
  CreateDirectory "$SMPROGRAMS\VideoLAN\Quick Settings"
     "$INSTDIR\vlc.exe" ""  
  CreateDirectory "$SMPROGRAMS\VideoLAN\Quick Settings\Audio"
SectionEnd  
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Audio\Set Audio mode to DirectX (default).lnk" \
    "$INSTDIR\vlc.exe" "--aout aout_directx --save-config vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Audio\Set Audio mode to Waveout.lnk" \
    "$INSTDIR\vlc.exe" "--aout waveout --save-config vlc://quit"
  CreateDirectory "$SMPROGRAMS\VideoLAN\Quick Settings\Interface"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Interface\Set Main Interface to Skinnable.lnk" \
    "$INSTDIR\vlc.exe" "-I skins --save-config vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Interface\Set Main Interface to Qt (default).lnk" \
    "$INSTDIR\vlc.exe" "-I qt --save-config vlc://quit"
  CreateDirectory "$SMPROGRAMS\VideoLAN\Quick Settings\Video"
  ; FIXME add detection for Vista. Direct3D will be default there, for all others it's DirectX
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to Direct3D.lnk" \
    "$INSTDIR\vlc.exe" "--vout direct3d --overlay --directx-hw-yuv --save-config vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to Direct3D (no hardware acceleration).lnk" \
    "$INSTDIR\vlc.exe" "--vout direct3d --overlay --no-directx-hw-yuv --save-config vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to DirectX.lnk" \
    "$INSTDIR\vlc.exe" "--vout directx --overlay --directx-hw-yuv --save-config vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to DirectX (no hardware acceleration).lnk" \
    "$INSTDIR\vlc.exe" "--vout directx --no-overlay --no-directx-hw-yuv --save-config vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to DirectX (no video overlay).lnk" \
    "$INSTDIR\vlc.exe" "--vout directx --no-overlay --directx-hw-yuv --save-config vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to OpenGL.lnk" \
    "$INSTDIR\vlc.exe" "--vout opengl --overlay --save-config vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Reset VLC media player preferences and cache files.lnk" \
    "$INSTDIR\vlc.exe" "--reset-config --reset-plugins-cache vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Documentation.lnk" \
    "$INSTDIR\Documentation.url"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Release Notes.lnk" \
    "$INSTDIR\NEWS.txt" ""
  CreateShortCut "$SMPROGRAMS\VideoLAN\${PRODUCT_GROUP} Website.lnk" \
    "$INSTDIR\${PRODUCT_GROUP} Website.url"
   CreateShortCut "$SMPROGRAMS\VideoLAN\VLC media player.lnk" \
     "$INSTDIR\vlc.exe" ""
SectionEnd


Section $Name_Section02b SEC02b
Section /o $Name_Section03 SEC03
   SectionIn 1 2 3
   SectionIn 3  
  CreateShortCut "$DESKTOP\VLC media player.lnk" \
    "$INSTDIR\vlc.exe" ""
SectionEnd


Section /o $Name_Section03 SEC03
  SetOutPath "$INSTDIR"
   SectionIn 3
  !insertmacro OpenUninstallLog
  !insertmacro InstallFile mozilla\npvlc.dll
   !insertmacro CloseUninstallLog


   SetOutPath "$INSTDIR"
   !define Moz "SOFTWARE\MozillaPlugins\@videolan.org/vlc,version=${VERSION}"  
   !insertmacro OpenUninstallLog
   WriteRegStr HKLM ${Moz} "Description" "VLC Multimedia Plugin"
   !insertmacro InstallFile mozilla\npvlc.dll
   WriteRegStr HKLM ${Moz} "Path" "$INSTDIR\npvlc.dll"
   !insertmacro InstallFile mozilla\npvlc.dll.manifest
   WriteRegStr HKLM ${Moz} "Product" "VLC media player"
   !insertmacro CloseUninstallLog
   WriteRegStr HKLM ${Moz} "Vendor" "VideoLAN"
  WriteRegStr HKLM ${Moz} "Version" "${VERSION}"


  !define Moz "SOFTWARE\MozillaPlugins\@videolan.org/vlc,version=${VERSION}"
; for very old version of mozilla, these lines may be needed
  WriteRegStr HKLM ${Moz} "Description" "VLC Multimedia Plugin"
;Push $R0
  WriteRegStr HKLM ${Moz} "Path" "$INSTDIR\npvlc.dll"
;Push $R1
  WriteRegStr HKLM ${Moz} "Product" "VLC media player"
;Push $R2
  WriteRegStr HKLM ${Moz} "Vendor" "VideoLAN"
  WriteRegStr HKLM ${Moz} "Version" "${VERSION}"


   
  ; for very old version of mozilla, these lines may be needed
  ;!define Index 'Line${__LINE__}'
  ;Push $R0
  ;StrCpy $R1 "0"
  ;Push $R1
;Push $R2


   
  ;!define Index 'Line${__LINE__}'
  ;"${Index}-Loop:"  
  ;StrCpy $R1 "0"


  ;"${Index}-Loop:"
  ; ; Check for Key
;  EnumRegKey $R0 HKLM "SOFTWARE\Mozilla" "$R1"
;  StrCmp $R0 "" "${Index}-End"
;  IntOp $R1 $R1 + 1
;  ReadRegStr $R2 HKLM "SOFTWARE\Mozilla\$R0\Extensions" "Plugins"
;  StrCmp $R2 "" "${Index}-Loop" ""  


   
  ;  ; Check for Key
  ;  CopyFiles "$INSTDIR\npvlc.dll" "$R2"  
  ;  EnumRegKey $R0 HKLM "SOFTWARE\Mozilla" "$R1"
  ;  !ifdef LIBVLC_DLL
  ;  StrCmp $R0 "" "${Index}-End"
;  CopyFiles ${LIBVLC_DLL} "$R2"  
  ;  IntOp $R1 $R1 + 1
  ;  !endif
  ;  ReadRegStr $R2 HKLM "SOFTWARE\Mozilla\$R0\Extensions" "Plugins"
;  !ifdef LIBVLC_CONTROL_DLL
  ;  StrCmp $R2 "" "${Index}-Loop" ""
  ;  CopyFiles ${LIBVLC_CONTROL_DLL} "$R2"  
  ;  !endif
;  Goto "${Index}-Loop"  


   
  ;  CopyFiles "$INSTDIR\npvlc.dll" "$R2"
  ;"${Index}-End:"  
;  !ifdef LIBVLC_DLL
  ;!undef Index  
  ; CopyFiles ${LIBVLC_DLL} "$R2"
;  !endif
;  !ifdef LIBVLC_CONTROL_DLL
;  CopyFiles ${LIBVLC_CONTROL_DLL} "$R2"
  ; !endif
;  Goto "${Index}-Loop"


   
  ;"${Index}-End:"
SectionEnd
;!undef Index


SectionEnd
Section $Name_Section04 SEC04
  SectionIn 1 3
  SetOutPath "$INSTDIR"
  !insertmacro OpenUninstallLog
  !insertmacro InstallFile activex\axvlc.dll
  !insertmacro CloseUninstallLog
  RegDLL "$INSTDIR\axvlc.dll"
SectionEnd  


Section $Name_Section04 SEC04
Section $Name_Section05 SEC05
   SectionIn 3
   SectionIn 1 2 3  
   SetOutPath "$INSTDIR"
   WriteRegStr HKCR "AudioCD\shell\PlayWithVLC" "" $ContextMenuEntry_PlayWith
   !insertmacro OpenUninstallLog
   WriteRegStr HKCR "AudioCD\shell\PlayWithVLC\command" "" \
  !insertmacro InstallFile activex\axvlc.dll
    "$INSTDIR\vlc.exe --started-from-file cdda://%1"
   !insertmacro InstallFile activex\axvlc.dll.manifest
   WriteRegStr HKCR "DVD\shell\PlayWithVLC" "" $ContextMenuEntry_PlayWith
   !insertmacro CloseUninstallLog
   WriteRegStr HKCR "DVD\shell\PlayWithVLC\command" "" \
  RegDLL "$INSTDIR\axvlc.dll"
    "$INSTDIR\vlc.exe --started-from-file dvd://%1"  
SectionEnd


SectionGroup /e !$Name_Section06 SEC05
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayDVDMovieOnArrival" "VLCPlayDVDMovieOnArrival" ""
   SectionGroup $Name_SectionGroupAudio
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "Action" $Action_OnArrivalDVD
    !insertmacro MacroAudioExtensions RegisterExtensionSection
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "DefaultIcon" '"$INSTDIR\vlc.exe",0'
   SectionGroupEnd
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "InvokeProgID" "VLC.DVDMovie"
   SectionGroup $Name_SectionGroupVideo
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "InvokeVerb" "play"
    !insertmacro MacroVideoExtensions RegisterExtensionSection
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "Provider" "VideoLAN VLC media player"
   SectionGroupEnd
   SectionGroup $Name_SectionGroupOther
    !insertmacro MacroOtherExtensions RegisterExtensionSection
   SectionGroupEnd
SectionGroupEnd


  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival" "VLCPlayCDAudioOnArrival" ""
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "Action" $Action_OnArrivalAudioCD
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "DefaultIcon" '"$INSTDIR\vlc.exe",0'
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "InvokeProgID" "VLC.CDAudio"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "InvokeVerb" "play"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "Provider" "VideoLAN VLC media player"
  WriteRegStr HKCR "VLC.DVDMovie" "" "VLC DVD Movie"
  WriteRegStr HKCR "VLC.DVDMovie\shell" "" "Play"
  WriteRegStr HKCR "VLC.DVDMovie\shell\Play\command" "" \
    '$INSTDIR\vlc.exe --started-from-file dvd://%1'
  WriteRegStr HKCR "VLC.DVDMovie\DefaultIcon" "" '"$INSTDIR\vlc.exe",0'
  WriteRegStr HKCR "VLC.CDAudio" "" "VLC CD Audio"
  WriteRegStr HKCR "VLC.CDAudio\shell" "" "Play"
  WriteRegStr HKCR "VLC.CDAudio\shell\Play\command" "" \
    '$INSTDIR\vlc.exe --started-from-file cdda://%1'
  WriteRegStr HKCR "VLC.CDAudio\DefaultIcon" "" '"$INSTDIR\vlc.exe",0'


Section $Name_Section05 SEC06
SectionEnd
  SectionIn 1 2 3
  WriteRegStr HKCR "AudioCD\shell\PlayWithVLC" "" $ContextMenuEntry_PlayWith
  WriteRegStr HKCR "AudioCD\shell\PlayWithVLC\command" "" \
    '"$INSTDIR\vlc.exe" --started-from-file cdda://%1'
  WriteRegStr HKCR "DVD\shell\PlayWithVLC" "" $ContextMenuEntry_PlayWith
  WriteRegStr HKCR "DVD\shell\PlayWithVLC\command" "" \
    '"$INSTDIR\vlc.exe" --started-from-file dvd://%1'


  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayDVDMovieOnArrival" "VLCPlayDVDMovieOnArrival" ""
SectionGroup $Name_Section06 SEC06
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "Action" $Action_OnArrivalDVD
   SectionGroup $Name_SectionGroupAudio
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "DefaultIcon" '"$INSTDIR\vlc.exe",0'
    !insertmacro MacroAudioExtensions RegisterExtensionSection
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "InvokeProgID" "VLC.DVDMovie"
  SectionGroupEnd
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "InvokeVerb" "play"
   SectionGroup $Name_SectionGroupVideo
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "Provider" "VideoLAN VLC media player"
    !insertmacro MacroVideoExtensions RegisterExtensionSection
   SectionGroupEnd
   SectionGroup $Name_SectionGroupOther
    !insertmacro MacroOtherExtensions RegisterExtensionSection
   SectionGroupEnd
SectionGroupEnd


  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival" "VLCPlayCDAudioOnArrival" ""
Section $Name_Section07 SEC07
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "Action" $Action_OnArrivalAudioCD
   SectionIn 3
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "DefaultIcon" '"$INSTDIR\vlc.exe",0'
   !insertmacro MacroAllExtensions AddContextMenu
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "InvokeProgID" "VLC.CDAudio"
   !insertmacro AddContextMenuExt "Directory"  
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "InvokeVerb" "play"
SectionEnd
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "Provider" "VideoLAN VLC media player"
  WriteRegStr HKCR "VLC.DVDMovie" "" "VLC DVD Movie"
  WriteRegStr HKCR "VLC.DVDMovie\shell" "" "Play"
  WriteRegStr HKCR "VLC.DVDMovie\shell\Play\command" "" \
    '"$INSTDIR\vlc.exe" --started-from-file dvd://%1'
   WriteRegStr HKCR "VLC.DVDMovie\DefaultIcon" "" '"$INSTDIR\vlc.exe",0'
   WriteRegStr HKCR "VLC.CDAudio" "" "VLC CD Audio"
   WriteRegStr HKCR "VLC.CDAudio\shell" "" "Play"
  WriteRegStr HKCR "VLC.CDAudio\shell\Play\command" "" \
    '"$INSTDIR\vlc.exe" --started-from-file cdda://%1'
  WriteRegStr HKCR "VLC.CDAudio\DefaultIcon" "" '"$INSTDIR\vlc.exe",0'


SectionEnd
Section /o $Name_Section08 SEC08
  !insertmacro delprefs
SectionEnd  


Section $Name_Section07 SEC07
; Installer section descriptions
   SectionIn 1 3
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
   !insertmacro MacroAllExtensions AddContextMenu
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC01} $Desc_Section01
   !insertmacro AddContextMenuExt "Directory"
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC02a} $Desc_Section02a
SectionEnd
   !insertmacro MUI_DESCRIPTION_TEXT ${SEC02b} $Desc_Section02b
   !insertmacro MUI_DESCRIPTION_TEXT ${SEC03} $Desc_Section03
   !insertmacro MUI_DESCRIPTION_TEXT ${SEC04} $Desc_Section04
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC05} $Desc_Section05
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC06} $Desc_Section06
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC07} $Desc_Section07
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC08} $Desc_Section08
!insertmacro MUI_FUNCTION_DESCRIPTION_END


Section $Name_Section08 SEC08
;;; Start function
   !insertmacro delprefs
Function .onInit
SectionEnd
   !insertmacro MUI_LANGDLL_DISPLAY
 
  !include "languages\english.nsh"
  StrCmp $LANGUAGE ${LANG_FRENCH} French EndLanguageCmp
  French:
  !include "languages\french.nsh"
  EndLanguageCmp:


; Installer section descriptions
   ReadRegStr $R0  ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
   "UninstallString"
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC01} $Desc_Section01
   StrCmp $R0 "" done
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC02a} $Desc_Section02a
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC02b} $Desc_Section02b
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC03} $Desc_Section03
   !insertmacro MUI_DESCRIPTION_TEXT ${SEC04} $Desc_Section04
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC05} $Desc_Section05
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC06} $Desc_Section06
   !insertmacro MUI_DESCRIPTION_TEXT ${SEC07} $Desc_Section07
   !insertmacro MUI_DESCRIPTION_TEXT ${SEC08} $Desc_Section08
!insertmacro MUI_FUNCTION_DESCRIPTION_END


;;; Start function
   MessageBox MB_YESNO|MB_ICONEXCLAMATION $Message_AlreadyInstalled IDNO done
Function .onInit
   !insertmacro MUI_LANGDLL_DISPLAY


  !include "languages\english.nsh"
   ;Run the uninstaller
  StrCmp $LANGUAGE ${LANG_FRENCH} French 0
   ;uninst:
  StrCmp $LANGUAGE ${LANG_ITALIAN} Italian 0
    ClearErrors
  StrCmp $LANGUAGE ${LANG_HUNGARIAN} Hungarian 0
    ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
   StrCmp $LANGUAGE ${LANG_ROMANIAN} Romanian 0
   done:  
   StrCmp $LANGUAGE ${LANG_CATALAN} Catalan 0
 
  StrCmp $LANGUAGE ${LANG_BULGARIAN} Bulgarian 0
FunctionEnd
  StrCmp $LANGUAGE ${LANG_SLOVAK} Slovak 0
  StrCmp $LANGUAGE ${LANG_POLISH} Polish 0
  StrCmp $LANGUAGE ${LANG_DUTCH} Dutch 0
  StrCmp $LANGUAGE ${LANG_SIMPCHINESE} SChinese 0
  StrCmp $LANGUAGE ${LANG_FINNISH} Finnish 0
  StrCmp $LANGUAGE ${LANG_PORTUGUESEBR} Brazilian EndLanguageCmp
  French:
  !include "languages\french.nsh"
  Goto EndLanguageCmp
  Italian:
  !include "languages\italian.nsh"
  Goto EndLanguageCmp
  Hungarian:
  !include "languages\hungarian.nsh"
  Goto EndLanguageCmp
  Romanian:
  !include "languages\romanian.nsh"
  Goto EndLanguageCmp
   Catalan:
  !include "languages\catalan.nsh"
  Goto EndLanguageCmp
  Bulgarian:
  !include "languages\bulgarian.nsh"
  Goto EndLanguageCmp
  Slovak:
  !include "languages\slovak.nsh"
  Goto EndLanguageCmp
  Polish:
  !include "languages\polish.nsh"
  Goto EndLanguageCmp
  Dutch:
  !include "languages\dutch.nsh"
  Goto EndLanguageCmp
  Schinese:
  !include "languages\schinese.nsh"
  Goto EndLanguageCmp
  Finnish:
  !include "languages\finnish.nsh"
  Goto EndLanguageCmp
  Brazilian:
  !include "languages\brazilian_portuguese.nsh"
  EndLanguageCmp:


   ReadRegStr $R0  ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
;; End function
  "UninstallString"
Section -Post
   StrCmp $R0 "" done
   WriteUninstaller "$INSTDIR\uninstall.exe"
  WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "InstallDir" $INSTDIR
  WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "Version" "${VERSION}"  
   WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\vlc.exe"  


   MessageBox MB_YESNO|MB_ICONEXCLAMATION $Message_AlreadyInstalled IDNO done
   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
    "DisplayName" "$(^Name)"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
    "UninstallString" "$INSTDIR\uninstall.exe"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
    "DisplayIcon" "$INSTDIR\vlc.exe"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
    "DisplayVersion" "${PRODUCT_VERSION}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
    "URLInfoAbout" "${PRODUCT_WEB_SITE}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
    "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd


  ;Run the uninstaller
;;;;;;;;;;;;;;;;;;;;;;;;
  ;uninst:
; Uninstaller sections ;
    ClearErrors
;;;;;;;;;;;;;;;;;;;;;;;;
    ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
  done:


FunctionEnd
; TrimNewlines (copied from NSIS documentation)
; input, top of stack  (e.g. whatever$\r$\n)
; output, top of stack (replaces, with e.g. whatever)
; modifies no other variables.


;; End function
Function un.TrimNewlines
Section -Post
Exch $R0
  WriteUninstaller "$INSTDIR\uninstall.exe"
Push $R1
  WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "InstallDir" $INSTDIR
Push $R2
  WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "Version" "${VERSION}"
StrCpy $R1 0
  WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\vlc.exe"


  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
loop:
    "DisplayName" "$(^Name)"
  IntOp $R1 $R1 - 1
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
  StrCpy $R2 $R0 1 $R1
    "UninstallString" "$INSTDIR\uninstall.exe"
  StrCmp $R2 "$\r" loop
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
  StrCmp $R2 "$\n" loop
    "DisplayIcon" "$INSTDIR\vlc.exe"
  IntOp $R1 $R1 + 1
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
  IntCmp $R1 0 no_trim_needed
    "DisplayVersion" "${PRODUCT_VERSION}"
  StrCpy $R0 $R0 $R1
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
    "URLInfoAbout" "${PRODUCT_WEB_SITE}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
    "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd


;;;;;;;;;;;;;;;;;;;;;;;;
no_trim_needed:
; Uninstaller sections ;
  Pop $R2
;;;;;;;;;;;;;;;;;;;;;;;;
  Pop $R1
  Exch $R0
FunctionEnd


   
; TrimNewlines (copied from NSIS documentation)
Function un.RemoveEmptyDirs
; input, top of stack (e.g. whatever$\r$\n)
  Pop $9
; output, top of stack (replaces, with e.g. whatever)
  !define Index 'Line${__LINE__}'
; modifies no other variables.
  FindFirst $0 $1 "$INSTDIR$9*"
  StrCmp $0 "" "${Index}-End"
  "${Index}-Loop:"
    StrCmp $1 "" "${Index}-End"
    StrCmp $1 "." "${Index}-Next"
    StrCmp $1 ".." "${Index}-Next"
      Push $0
      Push $1
      Push $9
      Push "$9$1\"
      Call un.RemoveEmptyDirs
      Pop $9
      Pop $1
      Pop $0
    "${Index}-Remove:"
    RMDir "$INSTDIR$9$1"
    "${Index}-Next:"
    FindNext $0 $1
    Goto "${Index}-Loop"
  "${Index}-End:"
  FindClose $0
  !undef Index
FunctionEnd


   
Function un.TrimNewlines
Section "un.$Name_Section91" SEC91
  Exch $R0
  SectionIn 1 2 3 RO
Push $R1
  SetShellVarContext all
Push $R2
StrCpy $R1 0


   
  loop:
  !insertmacro MacroAllExtensions DeleteContextMenu
  IntOp $R1 $R1 - 1
  !insertmacro MacroAllExtensions UnRegisterExtensionSection
  StrCpy $R2 $R0 1 $R1
  !insertmacro DeleteContextMenuExt "Directory"  
  StrCmp $R2 "$\r" loop
  StrCmp $R2 "$\n" loop
  IntOp $R1 $R1 + 1
  IntCmp $R1 0 no_trim_needed
  StrCpy $R0 $R0 $R1


   
  no_trim_needed:
  ;remove activex plugin
  Pop $R2
  UnRegDLL "$INSTDIR\axvlc.dll"
  Pop $R1
  Delete /REBOOTOK "$INSTDIR\axvlc.dll"
  Exch $R0
FunctionEnd


Function un.RemoveEmptyDirs
   ;remove mozilla plugin
   Pop $9
   Push $R0
  !define Index 'Line${__LINE__}'
   Push $R1
   FindFirst $0 $1 "$INSTDIR$9*"
   Push $R2
  StrCmp $0 "" "${Index}-End"
  "${Index}-Loop:"
    StrCmp $1 "" "${Index}-End"
    StrCmp $1 "." "${Index}-Next"
    StrCmp $1 ".." "${Index}-Next"
      Push $0
      Push $1
      Push $9
      Push "$9$1\"
      Call un.RemoveEmptyDirs
      Pop $9
      Pop $1
      Pop $0
    "${Index}-Remove:"
    RMDir "$INSTDIR$9$1"
    "${Index}-Next:"
    FindNext $0 $1
    Goto "${Index}-Loop"
   "${Index}-End:"
   FindClose $0
  !undef Index
FunctionEnd


Section "un.$Name_Section91" SEC91
   !define Index 'Line${__LINE__}'
   SectionIn 1 2 3 RO
   StrCpy $R1 "0"
   SetShellVarContext all


  !insertmacro MacroAllExtensions DeleteContextMenu
   "${Index}-Loop:"  
  !insertmacro MacroAllExtensions UnRegisterExtensionSection
   !insertmacro DeleteContextMenuExt "Directory"


  ;remove activex plugin
    ; Check for Key
  UnRegDLL "$INSTDIR\axvlc.dll"
    EnumRegKey $R0 HKLM "SOFTWARE\Mozilla" "$R1"  
  Delete /REBOOTOK "$INSTDIR\axvlc.dll"
    StrCmp $R0 "" "${Index}-End"  
  Delete /REBOOTOK "$INSTDIR\axvlc.dll.manifest"
    IntOp $R1 $R1 + 1
    ReadRegStr $R2 HKLM "SOFTWARE\Mozilla\$R0\Extensions" "Plugins"
    StrCmp $R2 "" "${Index}-Loop" ""  


  ;remove mozilla plugin
    ; old files (0.8.5 and before) that may be lying around
  Push $R0
    Delete /REBOOTOK "$R2\npvlc.dll"
  Push $R1
    Delete /REBOOTOK "$R2\libvlc.dll"
  Push $R2
    Delete /REBOOTOK "$R2\vlcintf.xpt"
    Goto "${Index}-Loop"


   !define Index 'Line${__LINE__}'
   "${Index}-End:"
   StrCpy $R1 "0"
   !undef Index
  Delete /REBOOTOK "$INSTDIR\npvlc.dll"  


   "${Index}-Loop:"
   RMDir "$SMPROGRAMS\VideoLAN"  
  RMDir /r $SMPROGRAMS\VideoLAN


    ; Check for Key
  FileOpen $UninstallLog "$INSTDIR\uninstall.log" r
    EnumRegKey $R0 HKLM "SOFTWARE\Mozilla" "$R1"
  UninstallLoop:
     StrCmp $R0 "" "${Index}-End"
     ClearErrors
     IntOp $R1 $R1 + 1
    FileRead $UninstallLog $R0
     ReadRegStr $R2 HKLM "SOFTWARE\Mozilla\$R0\Extensions" "Plugins"
     IfErrors UninstallEnd
     StrCmp $R2 "" "${Index}-Loop" ""
    Push $R0
    Call un.TrimNewLines
     Pop $R0
    Delete "$INSTDIR\$R0"  
     Goto UninstallLoop
  UninstallEnd:
  FileClose $UninstallLog
  Delete "$INSTDIR\uninstall.log"  
  Delete "$INSTDIR\uninstall.exe"  
  Push "\"
  Call un.RemoveEmptyDirs
  RMDir "$INSTDIR"  


    ; old files (0.8.5 and before) that may be lying around
  DeleteRegKey HKLM Software\VideoLAN
    Delete /REBOOTOK "$R2\npvlc.dll"
    Delete /REBOOTOK "$R2\libvlc.dll"
    Delete /REBOOTOK "$R2\vlcintf.xpt"
    Goto "${Index}-Loop"


   "${Index}-End:"
  DeleteRegKey HKCR Applications\vlc.exe
   !undef Index
  DeleteRegKey HKCR AudioCD\shell\PlayWithVLC
   Delete /REBOOTOK "$INSTDIR\npvlc.dll"
   DeleteRegKey HKCR DVD\shell\PlayWithVLC
   Delete /REBOOTOK "$INSTDIR\npvlc.dll.manifest"
  DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayDVDMovieOnArrival" "VLCPlayDVDMovieOnArrival"  
   DeleteRegKey HKLM Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival
   DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival" "VLCPlayCDAudioOnArrival"  
   DeleteRegKey HKLM Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival
  DeleteRegKey HKLM Software\Clients\Media\VLC
  DeleteRegKey HKCR "VLC.MediaFile"  


   RMDir "$SMPROGRAMS\VideoLAN"
   DeleteRegKey HKLM \  
  RMDir /r $SMPROGRAMS\VideoLAN
    "SOFTWARE\MozillaPlugins\@videolan.org/vlc,version=${VERSION}"


  FileOpen $UninstallLog "$INSTDIR\uninstall.log" r
   DeleteRegKey HKLM \  
   UninstallLoop:
     "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"  
    ClearErrors
    FileRead $UninstallLog $R0
    IfErrors UninstallEnd
    Push $R0
    Call un.TrimNewLines
    Pop $R0
    Delete "$INSTDIR\$R0"
     Goto UninstallLoop
  UninstallEnd:
  FileClose $UninstallLog
  Delete "$INSTDIR\uninstall.log"
  Delete "$INSTDIR\uninstall.exe"
  Push "\"
  Call un.RemoveEmptyDirs
  RMDir "$INSTDIR"


   DeleteRegKey HKLM Software\VideoLAN
   Delete "$DESKTOP\VLC media player.lnk"


  DeleteRegKey HKCR Applications\vlc.exe
   DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"  
   DeleteRegKey HKCR AudioCD\shell\PlayWithVLC
   DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"  
  DeleteRegKey HKCR DVD\shell\PlayWithVLC
   SetAutoClose true
  DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayDVDMovieOnArrival" "VLCPlayDVDMovieOnArrival"
SectionEnd
   DeleteRegKey HKLM Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival
  DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival" "VLCPlayCDAudioOnArrival"
  DeleteRegKey HKLM Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival
   DeleteRegKey HKLM Software\Clients\Media\VLC
  DeleteRegKey HKCR "VLC.MediaFile"


  DeleteRegKey HKLM \
Section /o "un.$Name_Section92" SEC92
    "SOFTWARE\MozillaPlugins\@videolan.org/vlc,version=${VERSION}"
  !insertmacro delprefs
SectionEnd


   DeleteRegKey HKLM \
; Uninstaller section descriptions
    "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
   !insertmacro MUI_DESCRIPTION_TEXT ${SEC91} $Desc_Section91
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC92} $Desc_Section92
!insertmacro MUI_UNFUNCTION_DESCRIPTION_END


  Delete "$DESKTOP\VLC media player.lnk"
;Function un.onUninstSuccess
;  HideWindow
;  MessageBox MB_ICONINFORMATION|MB_OK \
;    "$(^Name) was successfully removed from your computer."  
;FunctionEnd


   DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
Function un.onInit
   DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
   !insertmacro MUI_UNGETLANGUAGE
   SetAutoClose true
 
SectionEnd
  !include "languages\english.nsh"  
   StrCmp $LANGUAGE ${LANG_FRENCH} French EndLanguageCmp
  French:
  !include "languages\french.nsh"  
   EndLanguageCmp:
 
FunctionEnd


Section /o "un.$Name_Section92" SEC92
  !insertmacro delprefs
SectionEnd
; Uninstaller section descriptions
!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC91} $Desc_Section91
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC92} $Desc_Section92
!insertmacro MUI_UNFUNCTION_DESCRIPTION_END
;Function un.onUninstSuccess
;  HideWindow
;  MessageBox MB_ICONINFORMATION|MB_OK \
;    "$(^Name) was successfully removed from your computer."
;FunctionEnd
Function un.onInit
  !insertmacro MUI_UNGETLANGUAGE
 
  !include "languages\english.nsh"
  StrCmp $LANGUAGE ${LANG_FRENCH} French 0
  StrCmp $LANGUAGE ${LANG_ITALIAN} Italian 0
  StrCmp $LANGUAGE ${LANG_HUNGARIAN} Hungarian 0
  StrCmp $LANGUAGE ${LANG_ROMANIAN} Romanian 0
  StrCmp $LANGUAGE ${LANG_CATALAN} Catalan 0
  StrCmp $LANGUAGE ${LANG_BULGARIAN} Bulgarian 0
  StrCmp $LANGUAGE ${LANG_SLOVAK} Slovak 0
  StrCmp $LANGUAGE ${LANG_POLISH} Polish 0
  StrCmp $LANGUAGE ${LANG_DUTCH} Dutch 0
  StrCmp $LANGUAGE ${LANG_SIMPCHINESE} SChinese 0
  StrCmp $LANGUAGE ${LANG_FINNISH} Finnish 0
  StrCmp $LANGUAGE ${LANG_PORTUGUESEBR} Brazilian EndLanguageCmp
  French:
  !include "languages\french.nsh"
  Goto EndLanguageCmp
  Italian:
  !include "languages\italian.nsh"
  Goto EndLanguageCmp
  Hungarian:
  !include "languages\hungarian.nsh"
  Goto EndLanguageCmp
  Romanian:
  !include "languages\romanian.nsh"
  Goto EndLanguageCmp
  Catalan:
  !include "languages\catalan.nsh"
  Goto EndLanguageCmp
  Bulgarian:
  !include "languages\bulgarian.nsh"
  Goto EndLanguageCmp
  Slovak:
  !include "languages\slovak.nsh"
  Goto EndLanguageCmp
  Polish:
  !include "languages\polish.nsh"
  Goto EndLanguageCmp
  Dutch:
  !include "languages\dutch.nsh"
  Goto EndLanguageCmp
  Schinese:
  !include "languages\schinese.nsh"
  Goto EndLanguageCmp
  Finnish:
  !include "languages\finnish.nsh"
  Goto EndLanguageCmp
  Brazilian:
  !include "languages\brazilian_portuguese.nsh"
  EndLanguageCmp:
 
FunctionEnd
</highlight-nsis>
</highlight-nsis>


[[Category:Real World Installers]]
[[Category:Real World Installers]]

Latest revision as of 09:31, 12 November 2012

Description

VLC media player is a free software media player by the VideoLAN project.

The Script

http://git.videolan.org/?p=vlc.git;a=blob;f=extras/package/win32/NSIS/vlc.win32.nsi.in;hb=HEAD (raw)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; NSIS installer script for vlc ;
; (http://nsis.sourceforge.net) ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
!include "languages\declaration.nsh"
 
!define PRODUCT_NAME "VLC media player"
!define VERSION @VERSION@
!define PRODUCT_VERSION @VERSION@
!define PRODUCT_GROUP "VideoLAN"
!define PRODUCT_PUBLISHER "VideoLAN Team"
!define PRODUCT_WEB_SITE "http://www.videolan.org"
!define PRODUCT_DIR_REGKEY "Software\VideoLAN\VLC"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define PRODUCT_ID "{ea92ef52-afe4-4212-bacb-dfe9fca94cd6}"
 
!define MUI_LANGDLL_REGISTRY_ROOT "HKLM"
!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_DIR_REGKEY}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Language"
 
@FILE_LIBVLCCORE_DLL@
@FILE_LIBVLC_DLL@
 
;;;;;;;;;;;;;;;;;;;;;;;;;
; General configuration ;
;;;;;;;;;;;;;;;;;;;;;;;;;
 
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile ..\vlc-${VERSION}-win32.exe
InstallDir "$PROGRAMFILES\VideoLAN\VLC"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
!ifdef NSIS_LZMA_COMPRESS_WHOLE
SetCompressor lzma
!else
SetCompressor /SOLID lzma
!endif
 
;ShowInstDetails show
;ShowUnInstDetails show
SetOverwrite ifnewer
CRCCheck on
BrandingText "${PRODUCT_GROUP} ${PRODUCT_NAME}"
 
InstType $Name_InstTypeRecommended
InstType $Name_InstTypeMinimum
InstType $Name_InstTypeFull
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; NSIS Modern User Interface configuration ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
; MUI 1.67 compatible ------
  !include "MUI.nsh"
 
; MUI Settings
  !define MUI_ABORTWARNING
  !define MUI_ICON "vlc.ico"
  !define MUI_UNICON "vlc.ico"
  !define MUI_COMPONENTSPAGE_SMALLDESC
 
; Installer pages
  ; Welcome page
    !define MUI_WELCOMEPAGE_TITLE_3LINES
    !insertmacro MUI_PAGE_WELCOME
  ; License page
    !insertmacro MUI_PAGE_LICENSE "COPYING.txt"
  ; Components page
    !insertmacro MUI_PAGE_COMPONENTS
  ; Directory page
    !insertmacro MUI_PAGE_DIRECTORY
  ; Instfiles page
    !insertmacro MUI_PAGE_INSTFILES
  ; Finish page
    !define MUI_FINISHPAGE_RUN "$INSTDIR\vlc.exe"
    !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\README.txt"
    !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
    !define MUI_FINISHPAGE_LINK $Link_VisitWebsite
    !define MUI_FINISHPAGE_LINK_LOCATION "http://www.videolan.org/vlc/"
    !define MUI_FINISHPAGE_NOREBOOTSUPPORT
    !insertmacro MUI_PAGE_FINISH
 
; Uninstaller pages
    !insertmacro MUI_UNPAGE_CONFIRM
    !insertmacro MUI_UNPAGE_COMPONENTS
    !insertmacro MUI_UNPAGE_INSTFILES
    !insertmacro MUI_UNPAGE_FINISH
 
; Language files
  !insertmacro MUI_LANGUAGE "English" # first language is the default language
  !insertmacro MUI_LANGUAGE "French"
  !insertmacro MUI_LANGUAGE "German"
  !insertmacro MUI_LANGUAGE "Spanish"
  !insertmacro MUI_LANGUAGE "SimpChinese"
  !insertmacro MUI_LANGUAGE "TradChinese"
  !insertmacro MUI_LANGUAGE "Japanese"
  !insertmacro MUI_LANGUAGE "Korean"
  !insertmacro MUI_LANGUAGE "Italian"
  !insertmacro MUI_LANGUAGE "Dutch"
  !insertmacro MUI_LANGUAGE "Danish"
  !insertmacro MUI_LANGUAGE "Swedish"
  !insertmacro MUI_LANGUAGE "Norwegian"
  !insertmacro MUI_LANGUAGE "Finnish"
  !insertmacro MUI_LANGUAGE "Greek"
  !insertmacro MUI_LANGUAGE "Russian"
  !insertmacro MUI_LANGUAGE "Portuguese"
  !insertmacro MUI_LANGUAGE "PortugueseBR"
  !insertmacro MUI_LANGUAGE "Arabic"
  !insertmacro MUI_LANGUAGE "Polish"
  !insertmacro MUI_LANGUAGE "Romanian"
  !insertmacro MUI_LANGUAGE "Slovak"
  !insertmacro MUI_LANGUAGE "Czech"
  !insertmacro MUI_LANGUAGE "Hungarian"
  !insertmacro MUI_LANGUAGE "Catalan"
  !insertmacro MUI_LANGUAGE "Bulgarian"
 
; Reserve files for solid compression
  !insertmacro MUI_RESERVEFILE_LANGDLL
  !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
 
; MUI end ------
 
;;;;;;;;;;;;;;;;;;;;;;;
; Macro and Functions ;
;;;;;;;;;;;;;;;;;;;;;;;
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 1. File type associations ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
;; Function that register one extension for VLC
Function RegisterExtension
  ; back up old value for extension $R0 (eg. ".opt")
  ReadRegStr $1 HKCR "$R0" ""
  StrCmp $1 "" NoBackup
    StrCmp $1 "VLC$R0" "NoBackup"
    WriteRegStr HKCR "$R0" "VLC.backup" $1
NoBackup:
  WriteRegStr HKCR "$R0" "" "VLC$R0"
  ReadRegStr $0 HKCR "VLC$R0" ""
  WriteRegStr HKCR "VLC$R0" "" "VLC media file ($R0)"
  WriteRegStr HKCR "VLC$R0\shell" "" "Play"
  WriteRegStr HKCR "VLC$R0\shell\Play" "" $ShellAssociation_Play
  WriteRegStr HKCR "VLC$R0\shell\Play\command" "" '"$INSTDIR\vlc.exe" --started-from-file "%1"'
  WriteRegStr HKCR "VLC$R0\DefaultIcon" "" '"$INSTDIR\vlc.exe",0'
 
;;; Vista Only part
  ; Vista detection
  ReadRegStr $R1 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
  StrCpy $R2 $R1 3
  StrCmp $R2 '6.0' ForVista ToEnd
ForVista:
  WriteRegStr HKLM "Software\Clients\Media\VLC\Capabilities\FileAssociations" "$R0" "VLC$R0"
 
ToEnd:
FunctionEnd
 
;; Function that removes one extension that VLC owns.
Function un.RegisterExtension
  ;start of restore script
  ReadRegStr $1 HKCR "$R0" ""
  StrCmp $1 "VLC$R0" 0 NoOwn ; only do this if we own it
    ; Read the old value from Backup
    ReadRegStr $1 HKCR "$R0" "VLC.backup"
    StrCmp $1 "" 0 Restore ; if backup="" then delete the whole key
      DeleteRegKey HKCR "$R0"
    Goto NoOwn
Restore:
      WriteRegStr HKCR "$R0" "" $1
      DeleteRegValue HKCR "$R0" "VLC.backup"
NoOwn:
    DeleteRegKey HKCR "VLC$R0" ;Delete key with association settings
    DeleteRegKey HKLM "Software\Clients\Media\VLC\Capabilities\FileAssociations\VLC$R0" ; for vista
FunctionEnd
 
!macro RegisterExtensionSection EXT
  Section ${EXT}
    SectionIn 1 3
    Push $R0
    StrCpy $R0 ${EXT}
    Call RegisterExtension
    Pop $R0
  SectionEnd
!macroend
 
!macro UnRegisterExtensionSection EXT
  Push $R0
  StrCpy $R0 ${EXT}
  Call un.RegisterExtension
  Pop $R0
!macroend
 
!macro WriteRegStrSupportedTypes EXT
  WriteRegStr HKCR Applications\vlc.exe\SupportedTypes ${EXT} ""
!macroend
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Extension lists  Macros                    ;
; Those macros calls the previous functions  ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
!macro MacroAudioExtensions _action
  !insertmacro ${_action} ".a52"
  !insertmacro ${_action} ".aac"
  !insertmacro ${_action} ".ac3"
  !insertmacro ${_action} ".dts"
  !insertmacro ${_action} ".flac"
  !insertmacro ${_action} ".m4a"
  !insertmacro ${_action} ".m4p"
  !insertmacro ${_action} ".mka"
  !insertmacro ${_action} ".mod"
  !insertmacro ${_action} ".mp1"
  !insertmacro ${_action} ".mp2"
  !insertmacro ${_action} ".mp3"
  !insertmacro ${_action} ".oma"
  !insertmacro ${_action} ".oga"
  !insertmacro ${_action} ".spx"
  !insertmacro ${_action} ".wav"
  !insertmacro ${_action} ".wma"
  !insertmacro ${_action} ".wv"
  !insertmacro ${_action} ".xm"
!macroend
 
!macro MacroVideoExtensions _action
  !insertmacro ${_action} ".asf"
  !insertmacro ${_action} ".avi"
  !insertmacro ${_action} ".divx"
  !insertmacro ${_action} ".dv"
  !insertmacro ${_action} ".flv"
  !insertmacro ${_action} ".gxf"
  !insertmacro ${_action} ".m1v"
  !insertmacro ${_action} ".m2v"
  !insertmacro ${_action} ".m2ts"
  !insertmacro ${_action} ".m4v"
  !insertmacro ${_action} ".mkv"
  !insertmacro ${_action} ".mov"
  !insertmacro ${_action} ".mp4"
  !insertmacro ${_action} ".mpeg"
  !insertmacro ${_action} ".mpeg1"
  !insertmacro ${_action} ".mpeg2"
  !insertmacro ${_action} ".mpeg4"
  !insertmacro ${_action} ".mpg"
  !insertmacro ${_action} ".mts"
  !insertmacro ${_action} ".mxf"
  !insertmacro ${_action} ".nuv"
  !insertmacro ${_action} ".ogg"
  !insertmacro ${_action} ".ogm"
  !insertmacro ${_action} ".ogx"
  !insertmacro ${_action} ".ogv"
  !insertmacro ${_action} ".rmvb"
  !insertmacro ${_action} ".ts"
  !insertmacro ${_action} ".vob"
  !insertmacro ${_action} ".wmv"
!macroend
 
!macro MacroOtherExtensions _action
  !insertmacro ${_action} ".asx"
  !insertmacro ${_action} ".bin"
  !insertmacro ${_action} ".cue"
  !insertmacro ${_action} ".m3u"
  !insertmacro ${_action} ".pls"
  !insertmacro ${_action} ".vlc"
  !insertmacro ${_action} ".xspf"
!macroend
 
; One macro to rule them all
!macro MacroAllExtensions _action
  !insertmacro MacroAudioExtensions ${_action}
  !insertmacro MacroVideoExtensions ${_action}
  !insertmacro MacroOtherExtensions ${_action}
!macroend
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 2. Context menu entries ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
; Generic function for adding the context menu for one ext.
!macro AddContextMenuExt EXT
  WriteRegStr HKCR ${EXT}\shell\PlayWithVLC "" $ContextMenuEntry_PlayWith
  WriteRegStr HKCR ${EXT}\shell\PlayWithVLC\command "" '"$INSTDIR\vlc.exe" --started-from-file --no-playlist-enqueue "%1"'
 
  WriteRegStr HKCR ${EXT}\shell\AddToPlaylistVLC "" $ContextMenuEntry_AddToPlaylist
  WriteRegStr HKCR ${EXT}\shell\AddToPlaylistVLC\command "" '"$INSTDIR\vlc.exe" --started-from-file --playlist-enqueue "%1"'
!macroend
 
!macro AddContextMenu EXT
  Push $R0
  ReadRegStr $R0 HKCR ${EXT} ""
  !insertmacro AddContextMenuExt $R0
  Pop $R0
!macroend
 
!macro DeleteContextMenuExt EXT
  DeleteRegKey HKCR ${EXT}\shell\PlayWithVLC
  DeleteRegKey HKCR ${EXT}\shell\AddToPlaylistVLC
!macroend
 
!macro DeleteContextMenu EXT
  Push $R0
  ReadRegStr $R0 HKCR ${EXT} ""
  !insertmacro DeleteContextMenuExt $R0
  Pop $R0
!macroend
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 3. Delete prefs and cache ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
!macro delprefs
  StrCpy $0 0
  !define Index 'Line${__LINE__}'
  "${Index}-Loop:"
  ; FIXME
  ; this will loop through all the logged users and "virtual" windows users
  ; (it looks like users are only present in HKEY_USERS when they are logged in)
    ClearErrors
    EnumRegKey $1 HKU "" $0
    StrCmp $1 "" "${Index}-End"
    IntOp $0 $0 + 1
    ReadRegStr $2 HKU "$1\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" AppData
    StrCmp $2 "" "${Index}-Loop"
    RMDir /r "$2\vlc"
    Goto "${Index}-Loop"
  "${Index}-End:"
  !undef Index
!macroend
 
;;;;;;;;;;;;;;;
; 4. Logging  ;
;;;;;;;;;;;;;;;
Var UninstallLog
!macro OpenUninstallLog
  FileOpen $UninstallLog "$INSTDIR\uninstall.log" a
  FileSeek $UninstallLog 0 END
!macroend
 
!macro CloseUninstallLog
  FileClose $UninstallLog
  SetFileAttributes "$INSTDIR\uninstall.log" HIDDEN
!macroend
 
;;;;;;;;;;;;;;;;;;;;
; 5. Installations ;
;;;;;;;;;;;;;;;;;;;;
!macro InstallFile FILEREGEX
  File "${FILEREGEX}"
  !define Index 'Line${__LINE__}'
  FindFirst $0 $1 "$INSTDIR\${FILEREGEX}"
  StrCmp $0 "" "${Index}-End"
  "${Index}-Loop:"
    StrCmp $1 "" "${Index}-End"
    FileWrite $UninstallLog "$1$\r$\n"
    FindNext $0 $1
    Goto "${Index}-Loop"
  "${Index}-End:"
  !undef Index
!macroend
 
!macro InstallFolder FOLDER
  File /r "${FOLDER}"
  Push "${FOLDER}"
  Call InstallFolderInternal
!macroend
 
Function InstallFolderInternal
  Pop $9
  !define Index 'Line${__LINE__}'
  FindFirst $0 $1 "$INSTDIR\$9\*"
  StrCmp $0 "" "${Index}-End"
  "${Index}-Loop:"
    StrCmp $1 "" "${Index}-End"
    StrCmp $1 "." "${Index}-Next"
    StrCmp $1 ".." "${Index}-Next"
    IfFileExists "$9\$1\*" 0 "${Index}-Write"
      Push $0
      Push $9
      Push "$9\$1"
      Call InstallFolderInternal
      Pop $9
      Pop $0
      Goto "${Index}-Next"
    "${Index}-Write:"
    FileWrite $UninstallLog "$9\$1$\r$\n"
    "${Index}-Next:"
    FindNext $0 $1
    Goto "${Index}-Loop"
  "${Index}-End:"
  !undef Index
FunctionEnd
;;; End of Macros
 
 
;;;;;;;;;;;;;;;;;;;;;;
; Installer sections ;
; The CORE of the    ;
; installer          ;
;;;;;;;;;;;;;;;;;;;;;;
 
Section $Name_Section01 SEC01
  SectionIn 1 2 3 RO
  SetShellVarContext all
  SetOutPath "$INSTDIR"
 
  !insertmacro OpenUninstallLog
 
  ; VLC.exe, libvlc.dll
  !insertmacro InstallFile vlc.exe
  !insertmacro InstallFile vlc.exe.manifest
 
  ; All dlls
  !insertmacro InstallFile *.dll
 
  ; Text files
  !insertmacro InstallFile *.txt
 
  ; Subfolders
  !insertmacro InstallFolder plugins
  !insertmacro InstallFolder locale
  !insertmacro InstallFolder osdmenu
  !insertmacro InstallFolder skins
  !insertmacro InstallFolder http
  !insertmacro InstallFolder lua
 
  ; URLs
  WriteIniStr "$INSTDIR\${PRODUCT_GROUP} Website.url" "InternetShortcut" "URL" \
    "${PRODUCT_WEB_SITE}"
  FileWrite $UninstallLog "${PRODUCT_GROUP} Website.url$\r$\n"
  WriteIniStr "$INSTDIR\Documentation.url" "InternetShortcut" "URL" \
    "${PRODUCT_WEB_SITE}/doc/"
  FileWrite $UninstallLog "Documentation.url$\r$\n"
  WriteIniStr "$INSTDIR\New_Skins.url" "InternetShortcut" "URL" \
    "${PRODUCT_WEB_SITE}/vlc/skins.php"
  FileWrite $UninstallLog "New_Skins.url$\r$\n"
 
  !insertmacro CloseUninstallLog
 
  ; Add VLC to "recomended programs" for the following extensions
  WriteRegStr HKCR Applications\vlc.exe "" ""
  WriteRegStr HKCR Applications\vlc.exe "FriendlyAppName" "VLC media player"
  WriteRegStr HKCR Applications\vlc.exe\shell\Play "" $ContextMenuEntry_PlayWith
  WriteRegStr HKCR Applications\vlc.exe\shell\Play\command "" \
    '"$INSTDIR\vlc.exe" --started-from-file "%1"'
  !insertmacro MacroAllExtensions WriteRegStrSupportedTypes
 
; Vista Registration
  ; Vista detection
  ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
  StrCpy $R1 $R0 3
  StrCmp $R1 '6.0' lbl_vista lbl_done
 
  lbl_vista:
  WriteRegStr HKLM "Software\RegisteredApplications" "VLC" "Software\Clients\Media\VLC\Capabilities"
  WriteRegStr HKLM "Software\Clients\Media\VLC\Capabilities" "ApplicationName" "VLC media player"
  WriteRegStr HKLM "Software\Clients\Media\VLC\Capabilities" "ApplicationDescription" "VLC - The video swiss knife"
 
  lbl_done:
SectionEnd
 
Section $Name_Section02a SEC02a
  SectionIn 1 2 3
  CreateDirectory "$SMPROGRAMS\VideoLAN"
  CreateDirectory "$SMPROGRAMS\VideoLAN\Quick Settings"
  CreateDirectory "$SMPROGRAMS\VideoLAN\Quick Settings\Audio"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Audio\Set Audio mode to DirectX (default).lnk" \
    "$INSTDIR\vlc.exe" "--aout aout_directx --save-config vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Audio\Set Audio mode to Waveout.lnk" \
    "$INSTDIR\vlc.exe" "--aout waveout --save-config vlc://quit"
  CreateDirectory "$SMPROGRAMS\VideoLAN\Quick Settings\Interface"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Interface\Set Main Interface to Skinnable.lnk" \
    "$INSTDIR\vlc.exe" "-I skins --save-config vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Interface\Set Main Interface to Qt (default).lnk" \
    "$INSTDIR\vlc.exe" "-I qt --save-config vlc://quit"
  CreateDirectory "$SMPROGRAMS\VideoLAN\Quick Settings\Video"
  ; FIXME add detection for Vista. Direct3D will be default there, for all others it's DirectX
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to Direct3D.lnk" \
    "$INSTDIR\vlc.exe" "--vout direct3d --overlay --directx-hw-yuv --save-config vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to Direct3D (no hardware acceleration).lnk" \
    "$INSTDIR\vlc.exe" "--vout direct3d --overlay --no-directx-hw-yuv --save-config vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to DirectX.lnk" \
    "$INSTDIR\vlc.exe" "--vout directx --overlay --directx-hw-yuv --save-config vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to DirectX (no hardware acceleration).lnk" \
    "$INSTDIR\vlc.exe" "--vout directx --no-overlay --no-directx-hw-yuv --save-config vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to DirectX (no video overlay).lnk" \
    "$INSTDIR\vlc.exe" "--vout directx --no-overlay --directx-hw-yuv --save-config vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to OpenGL.lnk" \
    "$INSTDIR\vlc.exe" "--vout opengl --overlay --save-config vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Reset VLC media player preferences and cache files.lnk" \
    "$INSTDIR\vlc.exe" "--reset-config --reset-plugins-cache vlc://quit"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Documentation.lnk" \
    "$INSTDIR\Documentation.url"
  CreateShortCut "$SMPROGRAMS\VideoLAN\Release Notes.lnk" \
    "$INSTDIR\NEWS.txt" ""
  CreateShortCut "$SMPROGRAMS\VideoLAN\${PRODUCT_GROUP} Website.lnk" \
    "$INSTDIR\${PRODUCT_GROUP} Website.url"
  CreateShortCut "$SMPROGRAMS\VideoLAN\VLC media player.lnk" \
    "$INSTDIR\vlc.exe" ""
SectionEnd
 
Section $Name_Section02b SEC02b
  SectionIn 1 2 3
  CreateShortCut "$DESKTOP\VLC media player.lnk" \
    "$INSTDIR\vlc.exe" ""
SectionEnd
 
Section /o $Name_Section03 SEC03
  SectionIn 3
 
  SetOutPath "$INSTDIR"
  !insertmacro OpenUninstallLog
  !insertmacro InstallFile mozilla\npvlc.dll
  !insertmacro InstallFile mozilla\npvlc.dll.manifest
  !insertmacro CloseUninstallLog
 
  !define Moz "SOFTWARE\MozillaPlugins\@videolan.org/vlc,version=${VERSION}"
  WriteRegStr HKLM ${Moz} "Description" "VLC Multimedia Plugin"
  WriteRegStr HKLM ${Moz} "Path" "$INSTDIR\npvlc.dll"
  WriteRegStr HKLM ${Moz} "Product" "VLC media player"
  WriteRegStr HKLM ${Moz} "Vendor" "VideoLAN"
  WriteRegStr HKLM ${Moz} "Version" "${VERSION}"
 
 ; for very old version of mozilla, these lines may be needed
 ;Push $R0
 ;Push $R1
 ;Push $R2
 
 ;!define Index 'Line${__LINE__}'
 ;StrCpy $R1 "0"
 
 ;"${Index}-Loop:"
 
 ;  ; Check for Key
 ;  EnumRegKey $R0 HKLM "SOFTWARE\Mozilla" "$R1"
 ;  StrCmp $R0 "" "${Index}-End"
 ;  IntOp $R1 $R1 + 1
 ;  ReadRegStr $R2 HKLM "SOFTWARE\Mozilla\$R0\Extensions" "Plugins"
 ;  StrCmp $R2 "" "${Index}-Loop" ""
 
 ;  CopyFiles "$INSTDIR\npvlc.dll" "$R2"
 ;  !ifdef LIBVLC_DLL
 ;  CopyFiles ${LIBVLC_DLL} "$R2"
 ;  !endif
 ;  !ifdef LIBVLC_CONTROL_DLL
 ;  CopyFiles ${LIBVLC_CONTROL_DLL} "$R2"
 ;  !endif
 ;  Goto "${Index}-Loop"
 
 ;"${Index}-End:"
 ;!undef Index
 
SectionEnd
 
Section $Name_Section04 SEC04
  SectionIn 3
  SetOutPath "$INSTDIR"
  !insertmacro OpenUninstallLog
  !insertmacro InstallFile activex\axvlc.dll
  !insertmacro InstallFile activex\axvlc.dll.manifest
  !insertmacro CloseUninstallLog
  RegDLL "$INSTDIR\axvlc.dll"
SectionEnd
 
SectionGroup /e !$Name_Section06 SEC05
  SectionGroup $Name_SectionGroupAudio
    !insertmacro MacroAudioExtensions RegisterExtensionSection
  SectionGroupEnd
  SectionGroup $Name_SectionGroupVideo
    !insertmacro MacroVideoExtensions RegisterExtensionSection
  SectionGroupEnd
  SectionGroup $Name_SectionGroupOther
    !insertmacro MacroOtherExtensions RegisterExtensionSection
  SectionGroupEnd
SectionGroupEnd
 
 
Section $Name_Section05 SEC06
  SectionIn 1 2 3
  WriteRegStr HKCR "AudioCD\shell\PlayWithVLC" "" $ContextMenuEntry_PlayWith
  WriteRegStr HKCR "AudioCD\shell\PlayWithVLC\command" "" \
    '"$INSTDIR\vlc.exe" --started-from-file cdda://%1'
  WriteRegStr HKCR "DVD\shell\PlayWithVLC" "" $ContextMenuEntry_PlayWith
  WriteRegStr HKCR "DVD\shell\PlayWithVLC\command" "" \
    '"$INSTDIR\vlc.exe" --started-from-file dvd://%1'
 
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayDVDMovieOnArrival" "VLCPlayDVDMovieOnArrival" ""
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "Action" $Action_OnArrivalDVD
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "DefaultIcon" '"$INSTDIR\vlc.exe",0'
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "InvokeProgID" "VLC.DVDMovie"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "InvokeVerb" "play"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "Provider" "VideoLAN VLC media player"
 
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival" "VLCPlayCDAudioOnArrival" ""
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "Action" $Action_OnArrivalAudioCD
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "DefaultIcon" '"$INSTDIR\vlc.exe",0'
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "InvokeProgID" "VLC.CDAudio"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "InvokeVerb" "play"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "Provider" "VideoLAN VLC media player"
  WriteRegStr HKCR "VLC.DVDMovie" "" "VLC DVD Movie"
  WriteRegStr HKCR "VLC.DVDMovie\shell" "" "Play"
  WriteRegStr HKCR "VLC.DVDMovie\shell\Play\command" "" \
    '"$INSTDIR\vlc.exe" --started-from-file dvd://%1'
  WriteRegStr HKCR "VLC.DVDMovie\DefaultIcon" "" '"$INSTDIR\vlc.exe",0'
  WriteRegStr HKCR "VLC.CDAudio" "" "VLC CD Audio"
  WriteRegStr HKCR "VLC.CDAudio\shell" "" "Play"
  WriteRegStr HKCR "VLC.CDAudio\shell\Play\command" "" \
    '"$INSTDIR\vlc.exe" --started-from-file cdda://%1'
  WriteRegStr HKCR "VLC.CDAudio\DefaultIcon" "" '"$INSTDIR\vlc.exe",0'
 
SectionEnd
 
Section $Name_Section07 SEC07
  SectionIn 1 3
  !insertmacro MacroAllExtensions AddContextMenu
  !insertmacro AddContextMenuExt "Directory"
SectionEnd
 
Section $Name_Section08 SEC08
  !insertmacro delprefs
SectionEnd
 
; Installer section descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC01} $Desc_Section01
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC02a} $Desc_Section02a
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC02b} $Desc_Section02b
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC03} $Desc_Section03
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC04} $Desc_Section04
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC05} $Desc_Section05
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC06} $Desc_Section06
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC07} $Desc_Section07
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC08} $Desc_Section08
!insertmacro MUI_FUNCTION_DESCRIPTION_END
 
;;; Start function
Function .onInit
  !insertmacro MUI_LANGDLL_DISPLAY
 
  !include "languages\english.nsh"
  StrCmp $LANGUAGE ${LANG_FRENCH} French 0
  StrCmp $LANGUAGE ${LANG_ITALIAN} Italian 0
  StrCmp $LANGUAGE ${LANG_HUNGARIAN} Hungarian 0
  StrCmp $LANGUAGE ${LANG_ROMANIAN} Romanian 0
  StrCmp $LANGUAGE ${LANG_CATALAN} Catalan 0
  StrCmp $LANGUAGE ${LANG_BULGARIAN} Bulgarian 0
  StrCmp $LANGUAGE ${LANG_SLOVAK} Slovak 0
  StrCmp $LANGUAGE ${LANG_POLISH} Polish 0
  StrCmp $LANGUAGE ${LANG_DUTCH} Dutch 0
  StrCmp $LANGUAGE ${LANG_SIMPCHINESE} SChinese 0
  StrCmp $LANGUAGE ${LANG_FINNISH} Finnish 0
  StrCmp $LANGUAGE ${LANG_PORTUGUESEBR} Brazilian EndLanguageCmp
  French:
  !include "languages\french.nsh"
  Goto EndLanguageCmp
  Italian:
  !include "languages\italian.nsh"
  Goto EndLanguageCmp
  Hungarian:
  !include "languages\hungarian.nsh"
  Goto EndLanguageCmp
  Romanian:
  !include "languages\romanian.nsh"
  Goto EndLanguageCmp
  Catalan:
  !include "languages\catalan.nsh"
  Goto EndLanguageCmp
  Bulgarian:
  !include "languages\bulgarian.nsh"
  Goto EndLanguageCmp
  Slovak:
  !include "languages\slovak.nsh"
  Goto EndLanguageCmp
  Polish:
  !include "languages\polish.nsh"
  Goto EndLanguageCmp
  Dutch:
  !include "languages\dutch.nsh"
  Goto EndLanguageCmp
  Schinese:
  !include "languages\schinese.nsh"
  Goto EndLanguageCmp
  Finnish:
  !include "languages\finnish.nsh"
  Goto EndLanguageCmp
  Brazilian:
  !include "languages\brazilian_portuguese.nsh"
  EndLanguageCmp:
 
  ReadRegStr $R0  ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
  "UninstallString"
  StrCmp $R0 "" done
 
  MessageBox MB_YESNO|MB_ICONEXCLAMATION $Message_AlreadyInstalled IDNO done
 
  ;Run the uninstaller
  ;uninst:
    ClearErrors
    ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
  done:
 
FunctionEnd
 
;; End function
Section -Post
  WriteUninstaller "$INSTDIR\uninstall.exe"
  WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "InstallDir" $INSTDIR
  WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "Version" "${VERSION}"
  WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\vlc.exe"
 
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
    "DisplayName" "$(^Name)"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
    "UninstallString" "$INSTDIR\uninstall.exe"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
    "DisplayIcon" "$INSTDIR\vlc.exe"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
    "DisplayVersion" "${PRODUCT_VERSION}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
    "URLInfoAbout" "${PRODUCT_WEB_SITE}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
    "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd
 
;;;;;;;;;;;;;;;;;;;;;;;;
; Uninstaller sections ;
;;;;;;;;;;;;;;;;;;;;;;;;
 
; TrimNewlines (copied from NSIS documentation)
; input, top of stack  (e.g. whatever$\r$\n)
; output, top of stack (replaces, with e.g. whatever)
; modifies no other variables.
 
Function un.TrimNewlines
 Exch $R0
 Push $R1
 Push $R2
 StrCpy $R1 0
 
 loop:
   IntOp $R1 $R1 - 1
   StrCpy $R2 $R0 1 $R1
   StrCmp $R2 "$\r" loop
   StrCmp $R2 "$\n" loop
   IntOp $R1 $R1 + 1
   IntCmp $R1 0 no_trim_needed
   StrCpy $R0 $R0 $R1
 
 no_trim_needed:
   Pop $R2
   Pop $R1
   Exch $R0
FunctionEnd
 
Function un.RemoveEmptyDirs
  Pop $9
  !define Index 'Line${__LINE__}'
  FindFirst $0 $1 "$INSTDIR$9*"
  StrCmp $0 "" "${Index}-End"
  "${Index}-Loop:"
    StrCmp $1 "" "${Index}-End"
    StrCmp $1 "." "${Index}-Next"
    StrCmp $1 ".." "${Index}-Next"
      Push $0
      Push $1
      Push $9
      Push "$9$1\"
      Call un.RemoveEmptyDirs
      Pop $9
      Pop $1
      Pop $0
    "${Index}-Remove:"
    RMDir "$INSTDIR$9$1"
    "${Index}-Next:"
    FindNext $0 $1
    Goto "${Index}-Loop"
  "${Index}-End:"
  FindClose $0
  !undef Index
FunctionEnd
 
Section "un.$Name_Section91" SEC91
  SectionIn 1 2 3 RO
  SetShellVarContext all
 
  !insertmacro MacroAllExtensions DeleteContextMenu
  !insertmacro MacroAllExtensions UnRegisterExtensionSection
  !insertmacro DeleteContextMenuExt "Directory"
 
  ;remove activex plugin
  UnRegDLL "$INSTDIR\axvlc.dll"
  Delete /REBOOTOK "$INSTDIR\axvlc.dll"
  Delete /REBOOTOK "$INSTDIR\axvlc.dll.manifest"
 
  ;remove mozilla plugin
  Push $R0
  Push $R1
  Push $R2
 
  !define Index 'Line${__LINE__}'
  StrCpy $R1 "0"
 
  "${Index}-Loop:"
 
    ; Check for Key
    EnumRegKey $R0 HKLM "SOFTWARE\Mozilla" "$R1"
    StrCmp $R0 "" "${Index}-End"
    IntOp $R1 $R1 + 1
    ReadRegStr $R2 HKLM "SOFTWARE\Mozilla\$R0\Extensions" "Plugins"
    StrCmp $R2 "" "${Index}-Loop" ""
 
    ; old files (0.8.5 and before) that may be lying around
    Delete /REBOOTOK "$R2\npvlc.dll"
    Delete /REBOOTOK "$R2\libvlc.dll"
    Delete /REBOOTOK "$R2\vlcintf.xpt"
    Goto "${Index}-Loop"
 
  "${Index}-End:"
  !undef Index
  Delete /REBOOTOK "$INSTDIR\npvlc.dll"
  Delete /REBOOTOK "$INSTDIR\npvlc.dll.manifest"
 
  RMDir "$SMPROGRAMS\VideoLAN"
  RMDir /r $SMPROGRAMS\VideoLAN
 
  FileOpen $UninstallLog "$INSTDIR\uninstall.log" r
  UninstallLoop:
    ClearErrors
    FileRead $UninstallLog $R0
    IfErrors UninstallEnd
    Push $R0
    Call un.TrimNewLines
    Pop $R0
    Delete "$INSTDIR\$R0"
    Goto UninstallLoop
  UninstallEnd:
  FileClose $UninstallLog
  Delete "$INSTDIR\uninstall.log"
  Delete "$INSTDIR\uninstall.exe"
  Push "\"
  Call un.RemoveEmptyDirs
  RMDir "$INSTDIR"
 
  DeleteRegKey HKLM Software\VideoLAN
 
  DeleteRegKey HKCR Applications\vlc.exe
  DeleteRegKey HKCR AudioCD\shell\PlayWithVLC
  DeleteRegKey HKCR DVD\shell\PlayWithVLC
  DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayDVDMovieOnArrival" "VLCPlayDVDMovieOnArrival"
  DeleteRegKey HKLM Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival
  DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival" "VLCPlayCDAudioOnArrival"
  DeleteRegKey HKLM Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival
  DeleteRegKey HKLM Software\Clients\Media\VLC
  DeleteRegKey HKCR "VLC.MediaFile"
 
  DeleteRegKey HKLM \
    "SOFTWARE\MozillaPlugins\@videolan.org/vlc,version=${VERSION}"
 
  DeleteRegKey HKLM \
    "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
 
  Delete "$DESKTOP\VLC media player.lnk"
 
  DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
  DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
  SetAutoClose true
SectionEnd
 
Section /o "un.$Name_Section92" SEC92
  !insertmacro delprefs
SectionEnd
 
; Uninstaller section descriptions
!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC91} $Desc_Section91
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC92} $Desc_Section92
!insertmacro MUI_UNFUNCTION_DESCRIPTION_END
 
;Function un.onUninstSuccess
;  HideWindow
;  MessageBox MB_ICONINFORMATION|MB_OK \
;    "$(^Name) was successfully removed from your computer."
;FunctionEnd
 
Function un.onInit
  !insertmacro MUI_UNGETLANGUAGE
 
  !include "languages\english.nsh"
  StrCmp $LANGUAGE ${LANG_FRENCH} French 0
  StrCmp $LANGUAGE ${LANG_ITALIAN} Italian 0
  StrCmp $LANGUAGE ${LANG_HUNGARIAN} Hungarian 0
  StrCmp $LANGUAGE ${LANG_ROMANIAN} Romanian 0
  StrCmp $LANGUAGE ${LANG_CATALAN} Catalan 0
  StrCmp $LANGUAGE ${LANG_BULGARIAN} Bulgarian 0
  StrCmp $LANGUAGE ${LANG_SLOVAK} Slovak 0
  StrCmp $LANGUAGE ${LANG_POLISH} Polish 0
  StrCmp $LANGUAGE ${LANG_DUTCH} Dutch 0
  StrCmp $LANGUAGE ${LANG_SIMPCHINESE} SChinese 0
  StrCmp $LANGUAGE ${LANG_FINNISH} Finnish 0
  StrCmp $LANGUAGE ${LANG_PORTUGUESEBR} Brazilian EndLanguageCmp
  French:
  !include "languages\french.nsh"
  Goto EndLanguageCmp
  Italian:
  !include "languages\italian.nsh"
  Goto EndLanguageCmp
  Hungarian:
  !include "languages\hungarian.nsh"
  Goto EndLanguageCmp
  Romanian:
  !include "languages\romanian.nsh"
  Goto EndLanguageCmp
  Catalan:
  !include "languages\catalan.nsh"
  Goto EndLanguageCmp
  Bulgarian:
  !include "languages\bulgarian.nsh"
  Goto EndLanguageCmp
  Slovak:
  !include "languages\slovak.nsh"
  Goto EndLanguageCmp
  Polish:
  !include "languages\polish.nsh"
  Goto EndLanguageCmp
  Dutch:
  !include "languages\dutch.nsh"
  Goto EndLanguageCmp
  Schinese:
  !include "languages\schinese.nsh"
  Goto EndLanguageCmp
  Finnish:
  !include "languages\finnish.nsh"
  Goto EndLanguageCmp
  Brazilian:
  !include "languages\brazilian_portuguese.nsh"
  EndLanguageCmp:
 
FunctionEnd