Bump copyright year.
[mplayer-setup-win32.git] / MPUI_Common.nsh
blobda63cf1d697872c6502a56f3bb6df2a1f56c7e1a
1 ; ///////////////////////////////////////////////////////////////////////////////
2 ; // MPlayer for Windows - Install Script
3 ; // Copyright (C) 2004-2019 LoRd_MuldeR <MuldeR2@GMX.de>
4 ; //
5 ; // This program is free software; you can redistribute it and/or modify
6 ; // it under the terms of the GNU General Public License as published by
7 ; // the Free Software Foundation; either version 2 of the License, or
8 ; // (at your option) any later version.
9 ; //
10 ; // This program is distributed in the hope that it will be useful,
11 ; // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ; // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 ; // GNU General Public License for more details.
14 ; //
15 ; // You should have received a copy of the GNU General Public License along
16 ; // with this program; if not, write to the Free Software Foundation, Inc.,
17 ; // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 ; //
19 ; // http://www.gnu.org/licenses/gpl-2.0.txt
20 ; ///////////////////////////////////////////////////////////////////////////////
23 !define PrintProgress "!insertmacro _PrintProgress"
24 !define PrintStatus "!insertmacro _PrintStatus"
26 !macro _PrintProgress Text
27         SetDetailsPrint textonly
28         DetailPrint '${Text}, $(MPLAYER_LANG_STATUS_WAIT)...'
29         SetDetailsPrint listonly
30         DetailPrint '--- ${Text} ---'
31         Sleep 333
32 !macroend
34 !macro _PrintStatus Text
35         SetDetailsPrint textonly
36         DetailPrint '${Text}.'
37         SetDetailsPrint listonly
38         DetailPrint '--- ${Text} ---'
39         Sleep 333
40 !macroend
42 ; ----------------------------------------------------------------------------
44 !define ExtractSubDir "!insertmacro _ExtractSubDir"
46 !macro _ExtractSubDir BaseDir SubDir
47         SetOutPath "$INSTDIR\${SubDir}"
48         File /r "${BaseDir}\${SubDir}\*.*"
49 !macroend
51 ; ----------------------------------------------------------------------------
53 !define CreateWebLink "!insertmacro _CreateWebLink"
55 !macro _CreateWebLink ShortcutFile TargetURL
56         Push $0
57         Push $1
58         StrCpy $0 "${ShortcutFile}"
59         StrCpy $1 "${TargetURL}"
60         Call _Imp_CreateWebLink
61         Pop $1
62         Pop $0
63 !macroend
65 Function _Imp_CreateWebLink
66         FlushINI "$0"
67         SetFileAttributes "$0" FILE_ATTRIBUTE_NORMAL
68         DeleteINISec "$0" "DEFAULT"
69         DeleteINISec "$0" "InternetShortcut"
70         WriteINIStr "$0" "DEFAULT" "BASEURL" "$1"
71         WriteINIStr "$0" "InternetShortcut" "ORIGURL" "$1"
72         WriteINIStr "$0" "InternetShortcut" "URL" "$1"
73         WriteINIStr "$0" "InternetShortcut" "IconFile" "$SYSDIR\SHELL32.dll"
74         WriteINIStr "$0" "InternetShortcut" "IconIndex" "150"
75         FlushINI "$0"
76         SetFileAttributes "$0" FILE_ATTRIBUTE_READONLY
77 FunctionEnd
79 !macro DisableNextButton TmpVar
80         GetDlgItem ${TmpVar} $HWNDPARENT 1
81         EnableWindow ${TmpVar} 0
82 !macroend
84 ; ----------------------------------------------------------------------------
86 !define PackAll "!insertmacro _PackAll"
88 !macro _PackAll path filter
89         Push "${filter}"
90         Push "${path}"
91         Call _Imp_PackAll
92 !macroend
94 Function _Imp_PackAll
95         Exch $0
96         Exch
97         Exch $1
98         Push $2
100         ClearErrors
101         FindFirst $1 $2 "$0\$1"
103         ${IfNot} ${Errors}
104                 ${DoUntil} ${Errors}
105                         ${IfNot} "$2" == "Uninstall.exe"
106                         ${AndIfNot} "$2" == "Updater.exe"
107                                 DetailPrint "$(MPLAYER_LANG_COMPRESSING): $2"
108                                 NsExec::Exec '"$PLUGINSDIR\UPX.exe" --compress-icons=0 "$0\$2"'
109                         ${EndIf}
110                         FindNext $1 $2
111                 ${Loop}
112                 FindClose $1
113         ${EndIf}
115         Pop $2
116         Pop $1
117         Pop $0
118 FunctionEnd
119   
120 ; ----------------------------------------------------------------------------
121   
122 !define MakeFilePublic "!insertmacro _MakeFilePublic"
123 !define MakePathPublic "!insertmacro _MakePathPublic"
125 !macro _MakeFilePublic filename
126         ${IfNot} ${FileExists} "${filename}"
127                 Push $R0
128                 FileOpen $R0 "${filename}" w
129                 FileClose $R0
130                 Pop $R0
131         ${EndIf}
132         AccessControl::GrantOnFile "${filename}" "(BU)" "FullAccess"
133 !macroend
135 !macro _MakePathPublic path
136         AccessControl::GrantOnFile "${path}" "(BU)" "GenericRead + GenericWrite"
137 !macroend
139 ; ----------------------------------------------------------------------------
141 !define GetVirtualStorePath "!insertmacro _GetVirtualStorePath"
143 !macro _GetVirtualStorePath out path
144         StrCpy ${out} '${path}' "" 3
145         StrCpy ${out} '$LOCALAPPDATA\VirtualStore\${out}'
146 !macroend
148 ; ----------------------------------------------------------------------------
150 !define RegisterFileExtCapability "!insertmacro _RegisterFileExtCapability"
152 !macro _RegisterFileExtCapability ext
153         WriteRegStr HKLM "${MPlayerRegPath}\Capabilities\FileAssociations" ".${ext}"  "MPlayerForWindowsV2.File"
154 !macroend