-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathighp.nsi
149 lines (107 loc) · 4.1 KB
/
ighp.nsi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
;======================================================
; Include
!include "MUI2.nsh"
!include LogicLib.nsh
!include x64.nsh
;======================================================
;Version Information
!define UNINST_PATH "Software\Microsoft\Windows\CurrentVersion\Uninstall\ighp"
!define APP_NAME "iTunes Global Hotkeys Plugin"
!define VERSION "0.1.1"
;!define IS64BIT
VIProductVersion "${VERSION}.0"
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "${APP_NAME}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright (c) 2015 Stefan Cosma, pezcode"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "${APP_NAME} Setup"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${VERSION}.0"
;======================================================
; Installer Information
Name "${APP_NAME}"
!ifdef IS64BIT
OutFile "ighp_${VERSION}_x64.exe"
InstallDir "$PROGRAMFILES64\iTunes\Plug-ins"
!else
OutFile "ighp_${VERSION}.exe"
InstallDir "$PROGRAMFILES\iTunes\Plug-ins"
!endif
;======================================================
; Request application privileges for Windows Vista
RequestExecutionLevel admin
;======================================================
; Modern Interface Configuration
!define MUI_ABORTWARNING
!define MUI_FINISHPAGE
!define MUI_FINISHPAGE_TEXT "Thank you for installing ${APP_NAME}. You need to restart iTunes before using the plugin."
;======================================================
; Pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE License.txt
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;======================================================
; Languages
!insertmacro MUI_LANGUAGE "English"
;======================================================
; Sections
Section "64BitCheck"
!ifdef IS64BIT
${IfNot} ${RunningX64}
MessageBox MB_OK|MB_ICONEXCLAMATION "You are trying to install a 64-bit version of ${APP_NAME} on a 32-bit Windows.\r$\n\
Please use the appropriate 32-bit setup."
Quit
${EndIf}
!endif
SectionEnd
Section "VersionCheck"
Push $0
ReadRegStr $0 HKLM "${UNINST_PATH}" "DisplayVersion " ; old (pre 0.1.0) versions wrote the wrong reg key
StrCmp $0 "" check_new
; they use 2 dlls with other names, so we can't replace them
; enforce uninstall to prevent plugin from being loaded twice
goto abort_version
check_new:
ReadRegStr $0 HKLM "${UNINST_PATH}" "DisplayVersion"
StrCmp $0 "" end ; not found or error
; specific version checks here
;StrCmp $0 "0.0.4" abort_version
;StrCmp $0 "0.0.3" abort_version
;StrCmp $0 "0.0.2" abort_version
;StrCmp $0 "0.0.1" abort_version
goto end
abort_version:
MessageBox MB_OK|MB_ICONEXCLAMATION "Found an incompatible version of ${APP_NAME}$\r$\n\
Please remove it before installing a new version."
Quit
end:
Pop $0
SectionEnd
Section "Plugin"
SetOutPath $INSTDIR
!ifdef IS64BIT
File "x64\release\GlobalHotkeys.dll"
!else
File "release\GlobalHotkeys.dll"
!endif
File "/oname=Global Hotkeys License.txt" "License.txt"
File "/oname=Global Hotkeys Readme.txt" "Readme.txt"
;Create uninstaller
WriteUninstaller "$INSTDIR\UninstallGlobalHotkeys.exe"
WriteRegStr HKLM "${UNINST_PATH}" "DisplayName" "iTunes Global Hotkeys Plugin"
WriteRegStr HKLM "${UNINST_PATH}" "UninstallString" "$\"$INSTDIR\UninstallGlobalHotkeys.exe$\""
WriteRegStr HKLM "${UNINST_PATH}" "Publisher" "pezcode"
WriteRegStr HKLM "${UNINST_PATH}" "URLInfoAbout" "http://pezcode.github.com/ighp/"
WriteRegStr HKLM "${UNINST_PATH}" "DisplayVersion" "${VERSION}"
WriteRegDWORD HKLM "${UNINST_PATH}" "NoModify" 1
WriteRegDWORD HKLM "${UNINST_PATH}" "NoRepair" 1
SectionEnd
Section "Uninstall"
;Delete plugin files
Delete "$INSTDIR\GlobalHotkeys.dll"
Delete "$INSTDIR\Global Hotkeys License.txt"
Delete "$INSTDIR\Global Hotkeys Readme.txt"
Delete "$INSTDIR\UninstallGlobalHotkeys.exe"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ighp"
SectionEnd