OSDN Git Service

Installer fixes.
[lamexp/LameXP.git] / etc / NSIS / setup.nsi
1 ; ///////////////////////////////////////////////////////////////////////////////
2 ; // LameXP - Audio Encoder Front-End
3 ; // Copyright (C) 2004-2010 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 ; ///////////////////////////////////////////////////////////////////////////////
21
22 RequestExecutionLevel user
23 BrandingText `Date created: ${LAMEXP_DATE}`
24 ShowInstDetails show
25
26 !define ZIP2EXE_NAME `LameXP v${LAMEXP_VERSION} ${LAMEXP_SUFFIX} [Build #${LAMEXP_BUILD}]`
27 !define ZIP2EXE_OUTFILE `${LAMEXP_OUTPUT_FILE}`
28 !define ZIP2EXE_COMPRESSOR_LZMA
29 !define ZIP2EXE_COMPRESSOR_SOLID
30 !define ZIP2EXE_INSTALLDIR `$PROGRAMFILES\${ZIP2EXE_NAME}`
31
32 !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico"
33 !define MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\orange.bmp"
34 !define MUI_HEADERIMAGE
35 !define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\orange.bmp"
36 !define MUI_PAGE_CUSTOMFUNCTION_SHOW CheckForUpdate
37
38 VIAddVersionKey /LANG=${LANG_ENGLISH} "Author" "LoRd_MuldeR <mulder2@gmx.de>"
39 VIAddVersionKey /LANG=${LANG_ENGLISH} "Comments" "This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version."
40 VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "Free Software Foundation"
41 VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "LameXP v${LAMEXP_VERSION} ${LAMEXP_SUFFIX} [Build #${LAMEXP_BUILD}]"
42 VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${LAMEXP_DATE}.${LAMEXP_BUILD} (${LAMEXP_VERSION})"
43 VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright 2004-2010 LoRd_MuldeR"
44 VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" "GNU"
45 VIAddVersionKey /LANG=${LANG_ENGLISH} "OriginalFilename" "LameXP.${LAMEXP_DATE}.exe"
46 VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "LameXP - Audio Encoder Frontend"
47 VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "${LAMEXP_VERSION}, Build #${LAMEXP_BUILD} (${LAMEXP_DATE})"
48 VIAddVersionKey /LANG=${LANG_ENGLISH} "Website" "http://mulder.at.gg/"
49
50 !include `UAC.nsh`
51 !include `parameters.nsh`
52 !include `${NSISDIR}\Contrib\zip2exe\Base.nsh`
53 !include `${NSISDIR}\Contrib\zip2exe\Modern.nsh`
54
55 Function .onInit
56         UAC_TryAgain:
57         !insertmacro UAC_RunElevated
58         ${Switch} $0
59         ${Case} 0
60                 ${IfThen} $1 = 1 ${|} Quit ${|}
61                 ${IfThen} $3 <> 0 ${|} ${Break} ${|}
62                 ${If} $1 = 3
63                         MessageBox MB_ICONEXCLAMATION|MB_TOPMOST|MB_SETFOREGROUND|MB_OKCANCEL "This installer requires admin access, please try again!" /SD IDCANCEL IDOK UAC_TryAgain
64                 ${EndIf}
65         ${Case} 1223
66                 MessageBox MB_ICONEXCLAMATION|MB_TOPMOST|MB_SETFOREGROUND|MB_OKCANCEL "This installer requires admin privileges, please try again!" /SD IDCANCEL IDOK UAC_TryAgain
67                 Quit
68         ${Case} 1062
69                 MessageBox MB_ICONSTOP|MB_TOPMOST|MB_SETFOREGROUND "Logon service not running, aborting!"
70                 Quit
71         ${Default}
72                 MessageBox MB_ICONSTOP|MB_TOPMOST|MB_SETFOREGROUND "Unable to elevate installer! (Error code: $0)"
73                 Quit
74         ${EndSwitch}
75 FunctionEnd
76
77 Function .onInstSuccess
78         !insertmacro UAC_AsUser_Call Function LaunchApplication ${UAC_SYNCINSTDIR}
79 FunctionEnd
80
81 !insertmacro SECTION_BEGIN
82         File /r `${LAMEXP_SOURCE_PATH}\*.*`
83 !insertmacro SECTION_END
84
85 Function CheckForUpdate
86         !insertmacro GetCommandlineParameter "Update" "error" $R0
87         StrCmp $R0 "error" 0 +2
88         Return
89
90         FindWindow $R0 "#32770" "" $HWNDPARENT
91         GetDlgItem $R1 $R0 1019
92         SendMessage $R1 ${EM_SETREADONLY} 1 0
93
94         FindWindow $R0 "#32770" "" $HWNDPARENT
95         GetDlgItem $R1 $R0 1001
96         EnableWindow $R1 0
97
98         GetDlgItem $R1 $HWNDPARENT 1
99         SendMessage $R1 ${WM_SETTEXT} 0 "STR:Update"
100 FunctionEnd
101
102 Function LaunchApplication
103         ExecShell "explore" "$INSTDIR"
104         Exec '"$INSTDIR\LameXP.exe"'
105 FunctionEnd