]> git.sesse.net Git - vlc/blob - extras/package/win32/spad.nsi.in
nsis: Polish update
[vlc] / extras / package / win32 / spad.nsi.in
1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ; "set program as default" script for vlc                                        ;
3 ; more infos at http://msdn.microsoft.com/en-us/library/bb776851%28VS.85%29.aspx ;
4 ; and http://msdn.microsoft.com/en-us/library/bb776851%28VS.85%29.aspx           ;
5 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
7 !include LogicLib.nsh
8
9 Function GetOptions
10         !define GetOptions `!insertmacro GetOptionsCall`
11  
12         !macro GetOptionsCall _PARAMETERS _OPTION _RESULT
13                 Push `${_PARAMETERS}`
14                 Push `${_OPTION}`
15                 Call GetOptions
16                 Pop ${_RESULT}
17         !macroend
18  
19         Exch $1
20         Exch
21         Exch $0
22         Exch
23         Push $2
24         Push $3
25         Push $4
26         Push $5
27         Push $6
28         Push $7
29         ClearErrors
30  
31         StrCpy $2 $1 '' 1
32         StrCpy $1 $1 1
33         StrLen $3 $2
34         StrCpy $7 0
35  
36         begin:
37         StrCpy $4 -1
38         StrCpy $6 ''
39  
40         quote:
41         IntOp $4 $4 + 1
42         StrCpy $5 $0 1 $4
43         StrCmp $5$7 '0' notfound
44         StrCmp $5 '' trimright
45         StrCmp $5 '"' 0 +7
46         StrCmp $6 '' 0 +3
47         StrCpy $6 '"'
48         goto quote
49         StrCmp $6 '"' 0 +3
50         StrCpy $6 ''
51         goto quote
52         StrCmp $5 `'` 0 +7
53         StrCmp $6 `` 0 +3
54         StrCpy $6 `'`
55         goto quote
56         StrCmp $6 `'` 0 +3
57         StrCpy $6 ``
58         goto quote
59         StrCmp $5 '`' 0 +7
60         StrCmp $6 '' 0 +3
61         StrCpy $6 '`'
62         goto quote
63         StrCmp $6 '`' 0 +3
64         StrCpy $6 ''
65         goto quote
66         StrCmp $6 '"' quote
67         StrCmp $6 `'` quote
68         StrCmp $6 '`' quote
69         StrCmp $5 $1 0 quote
70         StrCmp $7 0 trimleft trimright
71  
72         trimleft:
73         IntOp $4 $4 + 1
74         StrCpy $5 $0 $3 $4
75         StrCmp $5 '' notfound
76         StrCmp $5 $2 0 quote
77         IntOp $4 $4 + $3
78         StrCpy $0 $0 '' $4
79         StrCpy $4 $0 1
80         StrCmp $4 ' ' 0 +3
81         StrCpy $0 $0 '' 1
82         goto -3
83         StrCpy $7 1
84         goto begin
85  
86         trimright:
87         StrCpy $0 $0 $4
88         StrCpy $4 $0 1 -1
89         StrCmp $4 ' ' 0 +3
90         StrCpy $0 $0 -1
91         goto -3
92         StrCpy $3 $0 1
93         StrCpy $4 $0 1 -1
94         StrCmp $3 $4 0 end
95         StrCmp $3 '"' +3
96         StrCmp $3 `'` +2
97         StrCmp $3 '`' 0 end
98         StrCpy $0 $0 -1 1
99         goto end
100  
101         notfound:
102         SetErrors
103         StrCpy $0 ''
104  
105         end:
106         Pop $7
107         Pop $6
108         Pop $5
109         Pop $4
110         Pop $3
111         Pop $2
112         Pop $1
113         Exch $0
114 FunctionEnd
115
116 ; Remove shortcuts
117 !macro HideIcons
118   WriteRegDWORD HKLM "Software\Clients\Media\VLC\InstallInfo" "IconsVisible" 0
119   SetShellVarContext all  ; Set $DESKTOP to All Users
120   ${Unless} ${FileExists} "$DESKTOP\VLC media player.lnk"
121     SetShellVarContext current  ; Set $DESKTOP to the current user's desktop
122   ${EndUnless}
123   ${If} ${FileExists} "$DESKTOP\VLC media player.lnk"
124     Delete "$DESKTOP\VLC media player.lnk"
125   ${EndIf}
126   ${If} ${FileExists} "$QUICKLAUNCH\VLC media player.lnk"
127     Delete "$QUICKLAUNCH\VLC media player.lnk"
128   ${EndIf}
129 !macroend
130 !define HideIcons "!insertmacro HideIcons"
131
132 ; Adds shortcuts 
133 !macro ShowIcons
134   WriteRegDWORD HKLM "Software\Clients\Media\VLC\InstallInfo" "IconsVisible" 1
135   SetShellVarContext all  ; Set $DESKTOP to All Users
136   ${Unless} ${FileExists} "$DESKTOP\VLC media player.lnk"
137     CreateShortCut "$DESKTOP\VLC media player.lnk" "$EXEDIR\vlc.exe" "" "$EXEDIR\vlc.exe" 0
138   ${EndUnless}
139   ${Unless} ${FileExists} "$QUICKLAUNCH\VLC media player.lnk"
140     CreateShortCut "$QUICKLAUNCH\VLC media player.lnk" "$EXEDIR\vlc.exe" "" "$EXEDIR\vlc.exe" 0
141   ${EndUnless}
142 !macroend
143 !define ShowIcons "!insertmacro ShowIcons"
144
145 !macro Reinstall
146     MessageBox MB_OK "Not implemented"
147 !macroend
148 !define Reinstall "!insertmacro reinstall"
149
150 Section
151   SetShellVarContext all
152   SetOutPath "$EXEDIR"
153
154     ${GetOptions} $CMDLINE "HideIcons"  $R0
155         IfErrors 0 +2
156         goto showIc
157     !insertmacro HideIcons
158     
159     showIc:
160     ${GetOptions} $CMDLINE "ShowIcons"  $R0
161     IfErrors 0 +2
162     goto reinst
163     !insertmacro ShowIcons
164     
165     reinst:
166     ${GetOptions} $CMDLINE "Reinstall"  $R0
167         IfErrors 0 +2
168         goto end
169     !insertmacro Reinstall
170     
171     end:
172 SectionEnd
173
174 ;"setup" is aded to the file name to trigger the UAC heuristic and request admin privileges
175 OutFile "spad-setup.exe"