Skip to content

Commit 7ee659e

Browse files
committed
Version check
1 parent 9df34ab commit 7ee659e

File tree

1 file changed

+66
-19
lines changed

1 file changed

+66
-19
lines changed

ighp.nsi

Lines changed: 66 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,37 @@
33

44
!include "MUI2.nsh"
55

6+
;======================================================
7+
;Version Information
8+
9+
!define UNINST_PATH "Software\Microsoft\Windows\CurrentVersion\Uninstall\ighp"
10+
11+
!define APP_NAME "iTunes Global Hotkeys Plugin"
12+
!define VERSION "0.1.0"
13+
14+
VIProductVersion "${VERSION}.0"
15+
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "${APP_NAME}"
16+
VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright (c) 2011 Stefan Cosma, pezcode"
17+
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "${APP_NAME} Setup"
18+
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${VERSION}.0"
19+
620
;======================================================
721
; Installer Information
822

9-
Name "iTunes Global Hotkeys Plugin v0.1.0"
10-
OutFile "ighp_0.1.0.exe"
23+
Name "${APP_NAME}"
24+
OutFile "ighp_${VERSION}.exe"
1125
InstallDir "$PROGRAMFILES\iTunes\Plug-ins"
1226

27+
;======================================================
28+
; Request application privileges for Windows Vista
29+
RequestExecutionLevel admin
30+
1331
;======================================================
1432
; Modern Interface Configuration
1533

1634
!define MUI_ABORTWARNING
1735
!define MUI_FINISHPAGE
18-
!define MUI_FINISHPAGE_TEXT "Thank you for installing iTunes Global Hotkeys Plugin. You need to restart iTunes before using the plugin"
36+
!define MUI_FINISHPAGE_TEXT "Thank you for installing ${APP_NAME}. You need to restart iTunes before using the plugin."
1937

2038
;======================================================
2139
; Pages
@@ -37,31 +55,60 @@ InstallDir "$PROGRAMFILES\iTunes\Plug-ins"
3755
;======================================================
3856
; Sections
3957

58+
Section "VersionCheck" versionCheck
59+
60+
Push $0
61+
62+
ReadRegStr $0 HKLM "${UNINST_PATH}" "DisplayVersion " ; old (pre 0.1.0) versions wrote the wrong reg key
63+
StrCmp $0 "" check_new
64+
65+
; they use 2 dlls with other names, so we can't replace them
66+
; enforce uninstall to prevent plugin from being loaded twice
67+
goto abort_version
68+
69+
check_new:
70+
71+
ReadRegStr $0 HKLM "${UNINST_PATH}" "DisplayVersion"
72+
StrCmp $0 "" end ; not found or error
73+
74+
; specific version checks here
75+
;StrCmp $0 "0.0.4" abort_version
76+
;StrCmp $0 "0.0.3" abort_version
77+
;StrCmp $0 "0.0.2" abort_version
78+
;StrCmp $0 "0.0.1" abort_version
79+
80+
goto end
81+
82+
abort_version:
83+
84+
MessageBox MB_OK|MB_ICONEXCLAMATION "Found an incompatible version of ${APP_NAME}$\r$\n\
85+
Please remove it before installing a new version."
86+
Quit
87+
88+
end:
89+
90+
Pop $0
91+
92+
SectionEnd
93+
4094
Section "Plugin" pluginSection
41-
; Version checking logic
42-
; TODO: for the next version
4395

4496
SetOutPath $INSTDIR
4597

4698
File "release\GlobalHotkeys.dll"
4799
File "/oname=Global Hotkeys License.txt" "License.txt"
48100
File "/oname=Global Hotkeys Readme.txt" "Readme.txt"
101+
49102
;Create uninstaller
103+
50104
WriteUninstaller "$INSTDIR\UninstallGlobalHotkeys.exe"
51-
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ighp" \
52-
"DisplayName" "iTunes Global Hotkeys Plugin"
53-
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ighp" \
54-
"UninstallString" "$\"$INSTDIR\UninstallGlobalHotkeys.exe$\""
55-
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ighp" \
56-
"Publisher" "pezcode"
57-
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ighp" \
58-
"URLInfoAbout" "https://github.com/pezcode/ighp"
59-
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ighp" \
60-
"DisplayVersion " "0.1.0"
61-
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ighp" \
62-
"NoModify" 1
63-
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ighp" \
64-
"NoRepair" 1
105+
WriteRegStr HKLM "${UNINST_PATH}" "DisplayName" "iTunes Global Hotkeys Plugin"
106+
WriteRegStr HKLM "${UNINST_PATH}" "UninstallString" "$\"$INSTDIR\UninstallGlobalHotkeys.exe$\""
107+
WriteRegStr HKLM "${UNINST_PATH}" "Publisher" "pezcode"
108+
WriteRegStr HKLM "${UNINST_PATH}" "URLInfoAbout" "http://pezcode.github.com/ighp/"
109+
WriteRegStr HKLM "${UNINST_PATH}" "DisplayVersion" "${VERSION}"
110+
WriteRegDWORD HKLM "${UNINST_PATH}" "NoModify" 1
111+
WriteRegDWORD HKLM "${UNINST_PATH}" "NoRepair" 1
65112

66113
SectionEnd
67114

0 commit comments

Comments
 (0)