This repository has been archived by the owner on Mar 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbassmididrv.nsi
287 lines (273 loc) · 11.6 KB
/
bassmididrv.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
!include "x64.nsh"
!include MUI2.nsh
!include WinVer.nsh
; The name of the installer
Name "BASSMIDI System Synth"
!ifdef INNER
!echo "Inner invocation"
OutFile "$%temp%\tempinstaller.exe"
SetCompress off
!else
!echo "Outer invocation"
!system "$\"${NSISDIR}\makensis$\" /DINNER bassmididrv.nsi" = 0
!system "$%TEMP%\tempinstaller.exe" = 2
!system "e:\signit.bat $%TEMP%\bassmididrvuninstall.exe" = 0
; The file to write
OutFile "bassmididrv.exe"
; Request application privileges for Windows Vista
RequestExecutionLevel admin
SetCompressor /solid lzma
!endif
;--------------------------------
; Pages
!insertmacro MUI_PAGE_WELCOME
Page Custom LockedListShow
!insertmacro MUI_PAGE_INSTFILES
UninstPage Custom un.LockedListShow
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
!macro DeleteOnReboot Path
IfFileExists `${Path}` 0 +3
SetFileAttributes `${Path}` NORMAL
Delete /rebootok `${Path}`
!macroend
!define DeleteOnReboot `!insertmacro DeleteOnReboot`
Function LockedListShow
${If} ${RunningX64}
File /oname=$PLUGINSDIR\LockedList64.dll `${NSISDIR}\Plugins\LockedList64.dll`
${EndIf}
!insertmacro MUI_HEADER_TEXT `File in use check` `Drive use check`
LockedList::AddModule \bassmididrv.dll
LockedList::Dialog /autonext
Pop $R0
FunctionEnd
Function un.LockedListShow
${If} ${RunningX64}
File /oname=$PLUGINSDIR\LockedList64.dll `${NSISDIR}\Plugins\LockedList64.dll`
${EndIf}
!insertmacro MUI_HEADER_TEXT `File in use check` `Drive use check`
LockedList::AddModule \bassmididrv.dll
LockedList::Dialog /autonext
Pop $R0
FunctionEnd
;--------------------------------
Function .onInit
!ifdef INNER
WriteUninstaller "$%TEMP%\bassmididrvuninstall.exe"
Quit
!endif
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BASSMIDI System Synth" "UninstallString"
StrCmp $R0 "" done
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"The MIDI driver is already installed. $\n$\nClick `OK` to remove the \
previous version or `Cancel` to cancel this upgrade." \
IDOK uninst
Abort
;Run the uninstaller
uninst:
ClearErrors
Exec $R0
Abort
done:
MessageBox MB_YESNO "This will install the BASSMIDI System Synth. Continue?" IDYES NoAbort
Abort ; causes installer to quit.
NoAbort:
FunctionEnd
; The stuff to install
Section "Needed (required)"
SectionIn RO
; Copy files according to whether its x64 or not.
DetailPrint "Copying driver and synth..."
${If} ${RunningX64}
SetOutPath "$WINDIR\SysWow64\bassmididrv"
File output\bass.dll
File output\basswasapi.dll
File output\bassflac.dll
File output\basswv.dll
File output\bassopus.dll
File output\bass_mpc.dll
File output\bassmidi.dll
File output\bassmididrv.dll
File output\bassmididrvcfg.exe
File output\sfpacker.exe
!ifndef INNER
File $%TEMP%\bassmididrvuninstall.exe
!endif
SetOutPath "$WINDIR\SysNative\bassmididrv"
File output\64\bass.dll
File output\64\basswasapi.dll
File output\64\bassflac.dll
File output\64\basswv.dll
File output\64\bassopus.dll
File output\64\bass_mpc.dll
File output\64\bassmidi.dll
File output\64\bassmididrv.dll
;check if already installed
StrCpy $1 "0"
LOOP1:
;k not installed, do checks
IntOp $1 $1 + 1
ClearErrors
ReadRegStr $0 HKLM "Software\Microsoft\Windows NT\CurrentVersion\Drivers32" "midi$1"
StrCmp $0 "" INSTALLDRIVER NEXTCHECK
NEXTCHECK:
StrCmp $0 "wdmaud.drv" 0 NEXT1
INSTALLDRIVER:
WriteRegStr HKLM "Software\Microsoft\Windows NT\CurrentVersion\Drivers32" "midi$1" "bassmididrv\bassmididrv.dll"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BASSMIDI System Synth\Backup" \
"MIDI" "midi$1"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BASSMIDI System Synth\Backup" \
"MIDIDRV" "$0"
Goto REGDONE32
NEXT1:
StrCmp $1 "9" 0 LOOP1
; check if 64 is installed
REGDONE32:
SetRegView 64
StrCpy $1 "0"
LOOP2:
;k not installed, do checks
IntOp $1 $1 + 1
ClearErrors
ReadRegStr $0 HKLM "Software\Microsoft\Windows NT\CurrentVersion\Drivers32" "midi$1"
StrCmp $0 "" INSTALLDRIVER2 NEXTCHECK2
NEXTCHECK2:
StrCmp $0 "wdmaud.drv" 0 NEXT2
INSTALLDRIVER2:
WriteRegStr HKLM "Software\Microsoft\Windows NT\CurrentVersion\Drivers32" "midi$1" "bassmididrv\bassmididrv.dll"
SetRegView 32
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BASSMIDI System Synth\Backup" \
"MIDI64" "midi$1"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BASSMIDI System Synth\Backup" \
"MIDIDRV64" "$0"
Goto REGDONE
NEXT2:
StrCmp $1 "9" 0 LOOP2
${Else}
SetOutPath "$WINDIR\System32\bassmididrv"
File output\bass.dll
File output\basswasapi.dll
File output\bassflac.dll
File output\basswv.dll
File output\bassopus.dll
File output\bass_mpc.dll
File output\bassmidi.dll
File output\bassmididrv.dll
File output\bassmididrvcfg.exe
File output\sfpacker.exe
!ifndef INNER
File $%TEMP%\bassmididrvuninstall.exe
!endif
;check if already installed
StrCpy $1 "0"
LOOP3:
;k not installed, do checks
IntOp $1 $1 + 1
ClearErrors
ReadRegStr $0 HKLM "Software\Microsoft\Windows NT\CurrentVersion\Drivers32" "midi$1"
StrCmp $0 "" INSTALLDRIVER3 NEXTCHECK3
NEXTCHECK3:
StrCmp $0 "wdmaud.drv" 0 NEXT3
INSTALLDRIVER3:
WriteRegStr HKLM "Software\Microsoft\Windows NT\CurrentVersion\Drivers32" "midi$1" "bassmididrv\bassmididrv.dll"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BASSMIDI System Synth\Backup" \
"MIDI" "midi$1"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BASSMIDI System Synth\Backup" \
"MIDIDRV" "$0"
Goto REGDONE
NEXT3:
StrCmp $1 "9" 0 LOOP3
${EndIf}
REGDONE:
; Write the uninstall keys
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BASSMIDI System Synth" "DisplayName" "BASSMIDI System Synth"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BASSMIDI System Synth" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BASSMIDI System Synth" "NoRepair" 1
WriteRegDWORD HKLM "Software\BASSMIDI Driver" "volume" "10000"
CreateDirectory "$SMPROGRAMS\BASSMIDI System Synth"
${If} ${RunningX64}
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BASSMIDI System Synth" "UninstallString" '"$WINDIR\SysWow64\bassmididrv\bassmididrvuninstall.exe"'
WriteRegStr HKLM "Software\BASSMIDI Driver" "path" "$WINDIR\SysWow64\bassmididrv"
CreateShortCut "$SMPROGRAMS\BASSMIDI System Synth\Uninstall.lnk" "$WINDIR\SysWow64\bassmididrv\bassmididrvuninstall.exe" "" "$WINDIR\SysWow64\bassmididrvuninstall.exe" 0
CreateShortCut "$SMPROGRAMS\BASSMIDI System Synth\SoundFont Packer.lnk" "$WINDIR\SysWow64\bassmididrv\sfpacker.exe" "" "$WINDIR\SysWow64\sfpacker.exe" 0
CreateShortCut "$SMPROGRAMS\BASSMIDI System Synth\Configure BASSMIDI Driver.lnk" "$WINDIR\SysWow64\bassmididrv\bassmididrvcfg.exe" "" "$WINDIR\SysWow64\bassmididrv\bassmididrvcfg.exe" 0
${Else}
WriteRegStr HKLM "Software\BASSMIDI Driver" "path" "$WINDIR\System32\bassmididrv"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BASSMIDI System Synth" "UninstallString" '"$WINDIR\System32\bassmididrv\bassmididrvuninstall.exe"'
CreateShortCut "$SMPROGRAMS\BASSMIDI System Synth\Uninstall.lnk" "$WINDIR\System32\bassmididrv\bassmididrvuninstall.exe" "" "$WINDIR\System32\bassmididrv\bassmididrvuninstall.exe" 0
CreateShortCut "$SMPROGRAMS\BASSMIDI System Synth\SoundFont Packer.lnk" "$WINDIR\System32\bassmididrv\sfpacker.exe" "" "$WINDIR\System32\sfpacker.exe" 0
CreateShortCut "$SMPROGRAMS\BASSMIDI System Synth\Configure BASSMIDI Driver.lnk" "$WINDIR\System32\bassmididrv\bassmididrvcfg.exe" "" "$WINDIR\System32\bassmididrv\bassmididrvcfg.exe" 0
${EndIf}
MessageBox MB_OK "Installation complete! Use the driver configuration tool which is in the 'BASSMIDI System Synth' program shortcut directory to configure the driver."
SectionEnd
;--------------------------------
; Uninstaller
!ifdef INNER
Section "Uninstall"
; Remove registry keys
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BASSMIDI System Synth\Backup" \
"MIDI"
ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BASSMIDI System Synth\Backup" \
"MIDIDRV"
WriteRegStr HKLM "Software\Microsoft\Windows NT\CurrentVersion\Drivers32" "$0" "$1"
${If} ${RunningX64}
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BASSMIDI System Synth\Backup" \
"MIDI64"
ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BASSMIDI System Synth\Backup" \
"MIDIDRV64"
SetRegView 64
WriteRegStr HKLM "Software\Microsoft\Windows NT\CurrentVersion\Drivers32" "$0" "$1"
SetRegView 32
${EndIf}
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BASSMIDI System Synth"
DeleteRegKey HKLM "Software\BASSMIDI Driver"
RMDir /r "$SMPROGRAMS\BASSMIDI System Synth"
${If} ${RunningX64}
${If} ${AtLeastWinVista}
RMDir /r "$WINDIR\SysWow64\bassmididrv"
RMDir /r "$WINDIR\SysNative\bassmididrv"
${Else}
MessageBox MB_OK "Note: The uninstaller will reboot your system to remove drivers."
${DeleteOnReboot} $WINDIR\SysWow64\bassmididrv\bass.dll
${DeleteOnReboot} $WINDIR\SysWow64\bassmididrv\basswasapi.dll
${DeleteOnReboot} $WINDIR\SysWow64\bassmididrv\bassmidi.dll
${DeleteOnReboot} $WINDIR\SysWow64\bassmididrv\bassmididrv.dll
${DeleteOnReboot} $WINDIR\SysWow64\bassmididrv\bass_mpc.dll
${DeleteOnReboot} $WINDIR\SysWow64\bassmididrv\bassmididrvuninstall.exe
${DeleteOnReboot} $WINDIR\SysWow64\bassmididrv\bassmididrvcfg.exe
${DeleteOnReboot} $WINDIR\SysWow64\bassmididrv\bassflac.dll
${DeleteOnReboot} $WINDIR\SysWow64\bassmididrv\basswv.dll
${DeleteOnReboot} $WINDIR\SysWow64\bassmididrv\bassopus.dll
${DeleteOnReboot} $WINDIR\SysWow64\bassmididrv\sfpacker.exe
${DeleteOnReboot} $WINDIR\SysNative\bassmididrv\bass.dll
${DeleteOnReboot} $WINDIR\SysNative\bassmididrv\basswasapi.dll
${DeleteOnReboot} $WINDIR\SysNative\bassmididrv\bassmidi.dll
${DeleteOnReboot} $WINDIR\SysNative\bassmididrv\bassmididrv.dll
${DeleteOnReboot} $WINDIR\SysNative\bassmididrv\bass_mpc.dll
${DeleteOnReboot} $WINDIR\SysNative\bassmididrv\bassflac.dll
${DeleteOnReboot} $WINDIR\SysNative\bassmididrv\basswv.dll
${DeleteOnReboot} $WINDIR\SysNative\bassmididrv\bassopus.dll
Reboot
${Endif}
${Else}
${If} ${AtLeastWinVista}
RMDir /r "$WINDIR\System32\bassmididrv"
${Else}
MessageBox MB_OK "Note: The uninstaller will reboot your system to remove drivers."
${DeleteOnReboot} $WINDIR\System32\bassmididrv\bass.dll
${DeleteOnReboot} $WINDIR\System32\bassmididrv\basswasapi.dll
${DeleteOnReboot} $WINDIR\System32\bassmididrv\bassmidi.dll
${DeleteOnReboot} $WINDIR\System32\bassmididrv\bassmididrv.dll
${DeleteOnReboot} $WINDIR\System32\bassmididrv\bass_mpc.dll
${DeleteOnReboot} $WINDIR\System32\bassmididrv\bassmididrvuninstall.exe
${DeleteOnReboot} $WINDIR\System32\bassmididrv\bassmididrvcfg.exe
${DeleteOnReboot} $WINDIR\System32\bassmididrv\bassflac.dll
${DeleteOnReboot} $WINDIR\System32\bassmididrv\basswv.dll
${DeleteOnReboot} $WINDIR\System32\bassmididrv\bassopus.dll
${DeleteOnReboot} $WINDIR\System32\bassmididrv\sfpacker.exe
Reboot
${Endif}
${EndIf}
SectionEnd
!endif