[vlc-devel] commit: Win32: add VLC to the "Set program access and computer defaults" dialog (Geoffroy Couprie )

git version control git at videolan.org
Sat Nov 28 21:17:51 CET 2009


vlc | branch: master | Geoffroy Couprie <geal at videolan.org> | Sat Nov 28 21:14:53 2009 +0100| [109d6eafdf886dc9b08cd64bb9fb10bdc4620dc6] | committer: Geoffroy Couprie 

Win32: add VLC to the "Set program access and computer defaults" dialog

The file associations need to be implemented

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=109d6eafdf886dc9b08cd64bb9fb10bdc4620dc6
---

 Makefile.am                           |    5 +-
 configure.ac                          |    1 +
 extras/package/win32/spad.nsi.in      |  175 +++++++++++++++++++++++++++++++++
 extras/package/win32/vlc.win32.nsi.in |    8 ++-
 4 files changed, 187 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 0f1146d..26cf733 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -53,6 +53,7 @@ EXTRA_DIST = \
 	extras/package/rpm/vlc.fedora.spec \
 	extras/package/rpm/vlc.altlinux.spec \
 	extras/package/win32/vlc.win32.nsi.in \
+	extras/package/win32/spad.nsi.in \
 	extras/package/win32/languages/declaration.nsh \
 	extras/package/win32/languages/english.nsh \
 	extras/package/win32/languages/french.nsh
@@ -60,7 +61,7 @@ EXTRA_DIST = \
 dist_noinst_SCRIPTS = bootstrap toolbox
 nodist_noinst_SCRIPTS = compile
 
-BUILT_SOURCES_distclean = vlc-config extras/package/win32/vlc.win32.nsi
+BUILT_SOURCES_distclean = vlc-config extras/package/win32/vlc.win32.nsi extras/package/win32/spad.nsi
 if HAVE_DARWIN
 BUILT_SOURCES_clean = macosx-sdk
 else
@@ -752,6 +753,7 @@ package-win32-base-debug: package-win-common
 # Copy relevant files
 # Script installer
 	cp "$(top_builddir)/extras/package/win32/vlc.win32.nsi" "$(win32_destdir)/"
+	cp "$(top_builddir)/extras/package/win32/spad.nsi" "$(win32_destdir)/"
 	mkdir "$(win32_destdir)/languages"
 	cp $(srcdir)/extras/package/win32/languages/*.nsh "$(win32_destdir)/languages/"
 
@@ -925,6 +927,7 @@ package-win32-base-exe: package-win32-base
 	else \
 	    echo 'Error: cannot locate makensis tool'; exit 1; \
 	fi; \
+	eval "$$MAKENSIS $(win32_destdir)/spad.nsi"
 	eval "$$MAKENSIS $(win32_destdir)/vlc.win32.nsi"
 
 package-win32-base-zip: package-win32-base
diff --git a/configure.ac b/configure.ac
index 89634ae..32a86c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5250,6 +5250,7 @@ dnl Create vlc-config.in
 VLC_OUTPUT_VLC_CONFIG_IN
 
 AC_CONFIG_FILES([
+  extras/package/win32/spad.nsi
   extras/package/win32/vlc.win32.nsi
   extras/package/macosx/Info.plist
   extras/package/macosx/Resources/English.lproj/InfoPlist.strings
diff --git a/extras/package/win32/spad.nsi.in b/extras/package/win32/spad.nsi.in
new file mode 100644
index 0000000..ffb782d
--- /dev/null
+++ b/extras/package/win32/spad.nsi.in
@@ -0,0 +1,175 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; "set program as default" script for vlc                                        ;
+; more infos at http://msdn.microsoft.com/en-us/library/bb776851%28VS.85%29.aspx ;
+; and http://msdn.microsoft.com/en-us/library/bb776851%28VS.85%29.aspx           ;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+!include LogicLib.nsh
+
+Function GetOptions
+	!define GetOptions `!insertmacro GetOptionsCall`
+ 
+	!macro GetOptionsCall _PARAMETERS _OPTION _RESULT
+		Push `${_PARAMETERS}`
+		Push `${_OPTION}`
+		Call GetOptions
+		Pop ${_RESULT}
+	!macroend
+ 
+	Exch $1
+	Exch
+	Exch $0
+	Exch
+	Push $2
+	Push $3
+	Push $4
+	Push $5
+	Push $6
+	Push $7
+	ClearErrors
+ 
+	StrCpy $2 $1 '' 1
+	StrCpy $1 $1 1
+	StrLen $3 $2
+	StrCpy $7 0
+ 
+	begin:
+	StrCpy $4 -1
+	StrCpy $6 ''
+ 
+	quote:
+	IntOp $4 $4 + 1
+	StrCpy $5 $0 1 $4
+	StrCmp $5$7 '0' notfound
+	StrCmp $5 '' trimright
+	StrCmp $5 '"' 0 +7
+	StrCmp $6 '' 0 +3
+	StrCpy $6 '"'
+	goto quote
+	StrCmp $6 '"' 0 +3
+	StrCpy $6 ''
+	goto quote
+	StrCmp $5 `'` 0 +7
+	StrCmp $6 `` 0 +3
+	StrCpy $6 `'`
+	goto quote
+	StrCmp $6 `'` 0 +3
+	StrCpy $6 ``
+	goto quote
+	StrCmp $5 '`' 0 +7
+	StrCmp $6 '' 0 +3
+	StrCpy $6 '`'
+	goto quote
+	StrCmp $6 '`' 0 +3
+	StrCpy $6 ''
+	goto quote
+	StrCmp $6 '"' quote
+	StrCmp $6 `'` quote
+	StrCmp $6 '`' quote
+	StrCmp $5 $1 0 quote
+	StrCmp $7 0 trimleft trimright
+ 
+	trimleft:
+	IntOp $4 $4 + 1
+	StrCpy $5 $0 $3 $4
+	StrCmp $5 '' notfound
+	StrCmp $5 $2 0 quote
+	IntOp $4 $4 + $3
+	StrCpy $0 $0 '' $4
+	StrCpy $4 $0 1
+	StrCmp $4 ' ' 0 +3
+	StrCpy $0 $0 '' 1
+	goto -3
+	StrCpy $7 1
+	goto begin
+ 
+	trimright:
+	StrCpy $0 $0 $4
+	StrCpy $4 $0 1 -1
+	StrCmp $4 ' ' 0 +3
+	StrCpy $0 $0 -1
+	goto -3
+	StrCpy $3 $0 1
+	StrCpy $4 $0 1 -1
+	StrCmp $3 $4 0 end
+	StrCmp $3 '"' +3
+	StrCmp $3 `'` +2
+	StrCmp $3 '`' 0 end
+	StrCpy $0 $0 -1 1
+	goto end
+ 
+	notfound:
+	SetErrors
+	StrCpy $0 ''
+ 
+	end:
+	Pop $7
+	Pop $6
+	Pop $5
+	Pop $4
+	Pop $3
+	Pop $2
+	Pop $1
+	Exch $0
+FunctionEnd
+
+; Remove shortcuts
+!macro HideIcons
+  WriteRegDWORD HKLM "Software\Clients\Media\VLC\InstallInfo" "IconsVisible" 0
+  SetShellVarContext all  ; Set $DESKTOP to All Users
+  ${Unless} ${FileExists} "$DESKTOP\VLC media player.lnk"
+    SetShellVarContext current  ; Set $DESKTOP to the current user's desktop
+  ${EndUnless}
+  ${If} ${FileExists} "$DESKTOP\VLC media player.lnk"
+    Delete "$DESKTOP\VLC media player.lnk"
+  ${EndIf}
+  ${If} ${FileExists} "$QUICKLAUNCH\VLC media player.lnk"
+    Delete "$QUICKLAUNCH\VLC media player.lnk"
+  ${EndIf}
+!macroend
+!define HideIcons "!insertmacro HideIcons"
+
+; Adds shortcuts 
+!macro ShowIcons
+  WriteRegDWORD HKLM "Software\Clients\Media\VLC\InstallInfo" "IconsVisible" 1
+  SetShellVarContext all  ; Set $DESKTOP to All Users
+  ${Unless} ${FileExists} "$DESKTOP\VLC media player.lnk"
+    CreateShortCut "$DESKTOP\VLC media player.lnk" "$EXEDIR\vlc.exe" "" "$EXEDIR\vlc.exe" 0
+  ${EndUnless}
+  ${Unless} ${FileExists} "$QUICKLAUNCH\VLC media player.lnk"
+    CreateShortCut "$QUICKLAUNCH\VLC media player.lnk" "$EXEDIR\vlc.exe" "" "$EXEDIR\vlc.exe" 0
+  ${EndUnless}
+!macroend
+!define ShowIcons "!insertmacro ShowIcons"
+
+!macro Reinstall
+    MessageBox MB_OK "Not implemented"
+!macroend
+!define Reinstall "!insertmacro reinstall"
+
+Section
+  SetShellVarContext all
+  SetOutPath "$EXEDIR"
+
+    ${GetOptions} $CMDLINE "HideIcons"  $R0
+	IfErrors 0 +2
+	goto showIc
+    !insertmacro HideIcons
+    
+    showIc:
+    ${GetOptions} $CMDLINE "ShowIcons"  $R0
+    IfErrors 0 +2
+    goto reinst
+    !insertmacro ShowIcons
+    
+    reinst:
+    ${GetOptions} $CMDLINE "Reinstall"  $R0
+	IfErrors 0 +2
+	goto end
+    !insertmacro Reinstall
+    
+    end:
+SectionEnd
+
+;"setup" is aded to the file name to trigger the UAC heuristic and request admin privileges
+OutFile "spad-setup.exe"
\ No newline at end of file
diff --git a/extras/package/win32/vlc.win32.nsi.in b/extras/package/win32/vlc.win32.nsi.in
index ce3469f..3cb8a47 100644
--- a/extras/package/win32/vlc.win32.nsi.in
+++ b/extras/package/win32/vlc.win32.nsi.in
@@ -441,7 +441,7 @@ Section $Name_Section01 SEC01
 
   !insertmacro CloseUninstallLog
 
-  ; Add VLC to "recomended programs" for the following extensions
+  ; Add VLC to "recommended 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\Open "" $ContextMenuEntry_PlayWith
@@ -459,6 +459,11 @@ Section $Name_Section01 SEC01
   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"
+  WriteRegStr HKLM "Software\Clients\Media\VLC" "" "VLC media player"
+  WriteRegStr HKLM "Software\Clients\Media\VLC\InstallInfo" "HideIconsCommand" "$\"$INSTDIR\spad-setup.exe$\" /HideIcons /S"
+  WriteRegStr HKLM "Software\Clients\Media\VLC\InstallInfo" "ShowIconsCommand" "$\"$INSTDIR\spad-setup.exe$\" /ShowIcons /S"
+  WriteRegStr HKLM "Software\Clients\Media\VLC\InstallInfo" "ReinstallCommand" "$\"$INSTDIR\spad-setup.exe$\" /Reinstall /S"
+  WriteRegDWORD HKLM "Software\Clients\Media\VLC\InstallInfo" "IconsVisible" 0x001
 
   lbl_done:
 SectionEnd
@@ -870,6 +875,7 @@ Section "un.$Name_Section91" SEC91
   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
+  DeleteRegValue HKLM "Software\RegisteredApplications" "VLC"
   DeleteRegKey HKCR "VLC.MediaFile"
 
   DeleteRegKey HKLM \




More information about the vlc-devel mailing list