1
0

dsp_sc_v2.nsi 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. ;--------------------------------
  2. ;Include Modern UI
  3. !include "MUI2.nsh"
  4. !include "LogicLib.nsh"
  5. !include "FileFunc.nsh"
  6. !include "WordFunc.nsh"
  7. !include "WinVer.nsh"
  8. ;--------------------------------
  9. ; this is the version for Winamp 5.9.1
  10. !define MINIMAL_VERSION "5.9.1.10021"
  11. ; The name of the installer
  12. !define NAME "Shoutcast Source DSP Plug-in"
  13. !define VERSION "2.4.2"
  14. !define BUILD "449"
  15. !define UNINSTALL "Shoutcast Source DSP"
  16. !define UNINSTALLER "uninstall_shoutcast-source-dsp-v2.exe"
  17. Name "${NAME}"
  18. BrandingText "${NAME} v${VERSION} Build ${BUILD}"
  19. ; detect winamp path from uninstall string if available
  20. InstallDirRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp" "UninstallString"
  21. ; The file to write
  22. OutFile "shoutcast-dsp-2-4-2-windows.exe"
  23. ; The default installation directory
  24. InstallDir "$PROGRAMFILES32\Winamp"
  25. ; The text to prompt the user to enter a directory
  26. DirText "Please select your Winamp path below (you will be able to proceed when Winamp is detected):"
  27. # currently doesn't work - DirShow hide
  28. ; Request application privileges for Windows Vista+
  29. RequestExecutionLevel admin
  30. ; Set the compressor (get installer as small as possible)
  31. SetCompressor /SOLID lzma
  32. ; Set the install types available
  33. InstType "Full Install"
  34. InstType "Base Install"
  35. ; global variables
  36. Var /GLOBAL WINAMP_INI_DIR
  37. Var GetInstalledSize.total
  38. ;--------------------------------
  39. ;Interface Settings
  40. !define MUI_ABORTWARNING
  41. ;--------------------------------
  42. ;Pages
  43. !define MUI_ICON "modern-install.ico"
  44. !define MUI_UNICON "modern-install.ico"
  45. !define MUI_WELCOMEPAGE_TITLE_3LINES
  46. !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of the ${NAME}.$\n$\nIt is recommended that you close all instances of Winamp before starting Setup. This will make it possible to install relevant files within your Winamp installation without issues.$\n$\nClick Next to continue."
  47. !define MUI_WELCOMEFINISHPAGE_BITMAP "win.bmp"
  48. !insertmacro MUI_PAGE_WELCOME
  49. !insertmacro MUI_PAGE_LICENSE "dsp_sc_license.txt"
  50. ; is best to call the version check when leaving the directory page so it will be working against correct path
  51. !define MUI_PAGE_CUSTOMFUNCTION_LEAVE CheckWinampVersion
  52. !insertmacro MUI_PAGE_DIRECTORY
  53. !insertmacro MUI_PAGE_COMPONENTS
  54. !insertmacro MUI_PAGE_INSTFILES
  55. !define MUI_FINISHPAGE_RUN
  56. !define MUI_FINISHPAGE_RUN_FUNCTION SetAsCurrentDSP
  57. !define MUI_FINISHPAGE_RUN_TEXT "Set as the current DSP plug-in"
  58. !define MUI_FINISHPAGE_SHOWREADME ; "$INSTDIR\winamp.exe"
  59. !define MUI_FINISHPAGE_SHOWREADME_FUNCTION RunWinamp
  60. !define MUI_FINISHPAGE_SHOWREADME_TEXT "Run Winamp"
  61. !define MUI_FINISHPAGE_TEXT_LARGE
  62. !define MUI_FINISHPAGE_TITLE_3LINES
  63. !define MUI_FINISHPAGE_TEXT "${NAME} has been installed.$\n$\nTo enable the plug-in if it is not your current DSP plug-in, goto Winamp Preferences -> Plug-ins -> DSP/Effect and select the '${NAME}' entry.$\n$\nClick Finish to close this wizard."
  64. !define MUI_PAGE_CUSTOMFUNCTION_SHOW RestoreCheckedStates
  65. !define MUI_PAGE_CUSTOMFUNCTION_LEAVE SaveCheckedStates
  66. !insertmacro MUI_PAGE_FINISH
  67. !define MUI_UNWELCOMEFINISHPAGE_BITMAP "win.bmp"
  68. !define MUI_UNWELCOMEPAGE_TEXT "This wizard will guide you through the uninstallation of the ${NAME}.$\n$\nBefore starting the uninstalltion, make sure Winamp and the ${NAME} are not running.$\n$\nClick Next to continue."
  69. !define MUI_UNFINISHPAGE_TEXT "${NAME} has been uninstalled from your Winamp install.$\n$\nClick Finish to close this wizard."
  70. !insertmacro MUI_UNPAGE_WELCOME
  71. !insertmacro MUI_UNPAGE_CONFIRM
  72. !insertmacro MUI_UNPAGE_INSTFILES
  73. !insertmacro MUI_UNPAGE_FINISH
  74. ;--------------------------------
  75. ;Languages
  76. !insertmacro MUI_LANGUAGE "English" ;first language is the default language
  77. ;--------------------------------
  78. ;Reserve Files
  79. ;If you are using solid compression, files that are required before
  80. ;the actual installation should be stored first in the data block,
  81. ;because this will make your installer start faster.
  82. !insertmacro MUI_RESERVEFILE_LANGDLL
  83. ;---------------------------------
  84. Section "Shoutcast Source DSP" Core
  85. SectionIn 1 2 RO
  86. SetOutPath "$INSTDIR\Plugins"
  87. File "dsp_sc.dll"
  88. ; look for lamedll.dll and remove as we now use lame_enc.dll
  89. IfFileExists "$INSTDIR\Plugins\lamedll.dll" 0 +2
  90. Delete "lamedll.dll"
  91. ; Let's upgrade to Lame 3.100.1
  92. SetOutPath "$INSTDIR\Shared"
  93. File "..\..\..\..\resources\libraries\lame_enc.dll"
  94. ; VC142 runtimes are required for Win7 & 8 installations
  95. ; Chances are these will already exist, but let's make sure anyway...
  96. ${If} ${AtLeastWin7}
  97. ${AndIf} ${AtMostWin8.1}
  98. SetOutPath "$INSTDIR\Microsoft.VC142.CRT"
  99. File ..\..\..\..\resources\libraries\msvcp140.dll
  100. File ..\..\..\..\resources\libraries\vcruntime140.dll
  101. File ..\..\..\..\resources\libraries\msvcp140_1.dll
  102. File ..\..\..\..\resources\libraries\msvcp140_2.dll
  103. File ..\..\..\..\resources\libraries\msvcp140_atomic_wait.dll
  104. File ..\..\..\..\resources\libraries\msvcp140_codecvt_ids.dll
  105. File ..\..\..\..\resources\libraries\vccorlib140.dll
  106. File ..\..\..\..\resources\libraries\concrt140.dll
  107. ${EndIf}
  108. ; Write the uninstall keys for Windows
  109. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL}" "DisplayName" "Shoutcast Source DSP Plug-in v2"
  110. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL}" "UninstallString" "$\"$INSTDIR\${UNINSTALLER}$\""
  111. WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL}" "NoModify" 1
  112. WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL}" "NoRepair" 1
  113. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL}" "Publisher" "Radionomy SA"
  114. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL}" "HelpLink" "http://forums.shoutcast.com/forumdisplay.php?f=140"
  115. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL}" "InstallLocation" "$INSTDIR\Plugins"
  116. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL}" "DisplayVersion" "${VERSION}.${BUILD}"
  117. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL}" "URLInfoAbout" "http://wiki.shoutcast.com/wiki/Source_DSP_Plug-in"
  118. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL}" "URLUpdateInfo" "https://www.shoutcast.com"
  119. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL}" "DisplayIcon" "$\"$INSTDIR\${UNINSTALLER}$\""
  120. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL}" "QuietUninstallString" "$\"$INSTDIR\${UNINSTALLER}$\" /S"
  121. Call GetInstalledSize
  122. WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL}" "EstimatedSize" "$GetInstalledSize.total"
  123. IfFileExists "$INSTDIR\Uninstallers\${UNINSTALLER}" 0 +2
  124. Delete "$INSTDIR\Uninstallers\${UNINSTALLER}"
  125. SetOutPath "$INSTDIR\"
  126. WriteUninstaller "$INSTDIR\${UNINSTALLER}"
  127. SectionEnd
  128. Section "Documentation" Docs
  129. SectionIn 1
  130. SetOutPath "$INSTDIR\Plugins\Shoutcast Source DSP"
  131. File ..\docs\Source_DSP_Plug-in.html
  132. File ..\docs\Source_DSP_Plug-in_Config_Examples.html
  133. File ..\docs\Source_DSP_Changelog.html
  134. SetOutPath "$INSTDIR\Plugins\Shoutcast Source DSP\res"
  135. File ..\docs\res\*.png
  136. SectionEnd
  137. ;--------------------------------
  138. ;Section description text
  139. !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  140. !insertmacro MUI_DESCRIPTION_TEXT ${Core} "The ${NAME} file.$\n$\n(This is always required)"
  141. !insertmacro MUI_DESCRIPTION_TEXT ${Docs} "This will be put in 'Plugins\Shoutcast Source DSP' in the selected destination.$\n$\nThese will show you the features available in the plug-in as well as how to make it connect with the Shoutcast 2 tools."
  142. !insertmacro MUI_FUNCTION_DESCRIPTION_END
  143. ;--------------------------------
  144. ;Uninstaller Section
  145. Section "Uninstall"
  146. DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL}"
  147. Delete "$INSTDIR\Plugins\dsp_sc.dll"
  148. Delete "$INSTDIR\Plugins\lamedll.dll" ; we don't actually install this any more
  149. ; Delete "$INSTDIR\Shared\lame_enc.dll"
  150. Delete "$INSTDIR\Plugins\Shoutcast Source DSP\dsp_sc.txt"
  151. Delete "$INSTDIR\Plugins\Shoutcast Source DSP\dsp_sc_config.txt"
  152. Delete "$INSTDIR\Plugins\Shoutcast Source DSP\Source_DSP_Plug-in.html"
  153. Delete "$INSTDIR\Plugins\Shoutcast Source DSP\Source_DSP_Changelog.html"
  154. Delete "$INSTDIR\Plugins\Shoutcast Source DSP\Source_DSP_Plug-in_Config_Examples.html"
  155. Delete "$INSTDIR\Plugins\Shoutcast Source DSP\res\*.png"
  156. Delete "$INSTDIR\Plugins\Shoutcast Source DSP\res\docs.css"
  157. RMDir "$INSTDIR\Plugins\Shoutcast Source DSP\res"
  158. RMDir "$INSTDIR\Plugins\Shoutcast Source DSP"
  159. ; Delete "$INSTDIR\Microsoft.VC142.CRT\*.dll" ; not wise, because then Winamp won't run on Win7-Win8.1 - - - why did this line exist for the VC90 Runtime?
  160. Delete "$INSTDIR\${UNINSTALLER}"
  161. SectionEnd
  162. Function .onInit
  163. !insertmacro MUI_LANGDLL_DISPLAY
  164. ;Detect running Winamp instances and close them
  165. !define WINAMP_FILE_EXIT 40001
  166. FindWindow $R0 "Winamp v1.x"
  167. IntCmp $R0 0 ok
  168. MessageBox MB_YESNO|MB_ICONEXCLAMATION "Please close all instances of Winamp before installing$\n${NAME}.$\n$\nAttempt to close Winamp now?" IDYES checkagain IDNO no
  169. checkagain:
  170. FindWindow $R0 "Winamp v1.x"
  171. IntCmp $R0 0 ok
  172. SendMessage $R0 ${WM_COMMAND} ${WINAMP_FILE_EXIT} 0
  173. Goto checkagain
  174. no:
  175. Abort
  176. ok:
  177. FunctionEnd
  178. Function .onVerifyInstDir
  179. ;Check for Winamp installation
  180. IfFileExists $INSTDIR\Winamp.exe Good
  181. Abort
  182. Good:
  183. FunctionEnd
  184. ;Uninstaller Functions
  185. /* Function un.GetParent
  186. Exch $R0
  187. Push $R1
  188. Push $R2
  189. Push $R3
  190. StrCpy $R1 0
  191. StrLen $R2 $R0
  192. loop:
  193. IntOp $R1 $R1 + 1
  194. IntCmp $R1 $R2 get 0 get
  195. StrCpy $R3 $R0 1 -$R1
  196. StrCmp $R3 "\" get
  197. Goto loop
  198. get:
  199. StrCpy $R0 $R0 -$R1
  200. Pop $R3
  201. Pop $R2
  202. Pop $R1
  203. Exch $R0
  204. FunctionEnd
  205. Function un.onInit
  206. !insertmacro MUI_UNGETLANGUAGE
  207. Push "$INSTDIR"
  208. Call un.GetParent
  209. Pop $R0
  210. StrCpy $INSTDIR $R0
  211. FunctionEnd */
  212. Function GetWinampIniPath
  213. StrCpy $WINAMP_INI_DIR $INSTDIR
  214. ${If} $0 == ""
  215. StrCpy $WINAMP_INI_DIR "$PROGRAMFILES\Winamp"
  216. ${EndIf}
  217. ClearErrors
  218. ${If} ${FileExists} "$WINAMP_INI_DIR\paths.ini"
  219. ReadINIStr $0 "$WINAMP_INI_DIR\paths.ini" "Winamp" "inidir"
  220. ${If} $0 != ""
  221. ${WordFind2X} $0 "{" "}" "E+1" $2
  222. ${If} ${Errors}
  223. ${IfNot} ${FileExists} "$0\*.*"
  224. ${WordFind2X} $0 "%" "%" "E+1" $2
  225. ${If} $2 == "WINAMP_ROOT_DIR"
  226. ClearErrors
  227. ${GetRoot} "$WINAMP_INI_DIR" $3
  228. ${WordReplace} "$0" "%$2%" "$3" "E+1" $R0
  229. ${If} ${Errors}
  230. Return
  231. ${Else}
  232. StrCpy $WINAMP_INI_DIR $R0
  233. ${EndIf}
  234. ${ElseIf} $2 == "WINAMP_PROGRAM_DIR"
  235. ClearErrors
  236. ${WordReplace} "$0" "%$2%" "$WINAMP_INI_DIR" "E+1" $R0
  237. ${If} ${Errors}
  238. Return
  239. ${Else}
  240. StrCpy $WINAMP_INI_DIR $R0
  241. ${EndIf}
  242. ${Else}
  243. ClearErrors
  244. ReadEnvStr $R0 "$2"
  245. ${If} $R0 != ""
  246. ${WordReplace} "$0" "%$2%" "$R0" "E+1" $R0
  247. ${If} ${Errors}
  248. Return
  249. ${Else}
  250. StrCpy $WINAMP_INI_DIR $R0
  251. ${EndIf}
  252. ${Else}
  253. Return
  254. ${EndIf}
  255. ${EndIf}
  256. ${Else}
  257. StrCpy $WINAMP_INI_DIR $0
  258. ${EndIf}
  259. ${Else}
  260. System::Call "shell32::SHGetSpecialFolderPath(i $HWNDPARENT, t .r4, i $2, i0) i .r3"
  261. ClearErrors
  262. ${WordReplace} "$0" "{$2}" "$4" "E+1" $R0
  263. ${If} ${Errors}
  264. Return
  265. ${Else}
  266. StrCpy $WINAMP_INI_DIR $R0
  267. ${EndIf}
  268. ${EndIf}
  269. ${Else}
  270. Return
  271. ${EndIf}
  272. ${Else}
  273. Return
  274. ${EndIf}
  275. FunctionEnd
  276. ; set as the current DSP
  277. Function SetAsCurrentDSP
  278. WriteINIStr "$WINAMP_INI_DIR\winamp.ini" "winamp" "dspplugin_name" "dsp_sc.dll"
  279. WriteINIStr "$WINAMP_INI_DIR\winamp.ini" "winamp" "dspplugin_num" "0"
  280. FunctionEnd
  281. Function RunWinamp
  282. StrCpy $1 1
  283. File "/oname=$PLUGINSDIR\ShellDispatch.dll" "ShellDispatch.dll"
  284. ${If} ${FileExists} "$PLUGINSDIR\ShellDispatch.dll"
  285. ${AndIf} ${FileExists} "$INSTDIR\winamp.exe"
  286. Push $0
  287. StrCpy $0 ""
  288. ClearErrors
  289. GetFullPathName /SHORT $0 "$PLUGINSDIR\ShellDispatch.dll"
  290. ${IfNot} ${Errors}
  291. ${AndIf} $0 != ""
  292. ExecWait 'rundll32.exe $0,RunDll_ShellExecute "open" "$INSTDIR\winamp.exe"' $1
  293. ${If} ${Errors}
  294. StrCpy $1 1
  295. ${EndIf}
  296. ${EndIf}
  297. Pop $0
  298. ${EndIf}
  299. ${If} $1 != 0
  300. Exec "$INSTDIR\winamp.exe"
  301. ${EndIf}
  302. FunctionEnd
  303. ; restore the last checked states on the finish page
  304. Function RestoreCheckedStates
  305. Call GetWinampIniPath
  306. ReadINIStr $0 "$WINAMP_INI_DIR\plugins\dsp_sc.ini" "installer" "cur"
  307. ${If} $0 == "0"
  308. ${NSD_Uncheck} $mui.FinishPage.Run
  309. ${EndIf}
  310. ReadINIStr $0 "$WINAMP_INI_DIR\plugins\dsp_sc.ini" "installer" "run"
  311. ${If} $0 == "0"
  312. ${NSD_Uncheck} $mui.FinishPage.ShowReadme
  313. ${EndIf}
  314. FunctionEnd
  315. ; save the last checked states on the finish page
  316. Function SaveCheckedStates
  317. ${NSD_GetState} $mui.FinishPage.Run $0
  318. WriteINIStr "$WINAMP_INI_DIR\plugins\dsp_sc.ini" "installer" "cur" $0
  319. ${NSD_GetState} $mui.FinishPage.ShowReadme $0
  320. WriteINIStr "$WINAMP_INI_DIR\plugins\dsp_sc.ini" "installer" "run" $0
  321. FunctionEnd
  322. ; the check version function
  323. ; only issue is that the strings won't be localised as i see the installer in the zip supports it
  324. Function CheckWinampVersion
  325. ${GetFileVersion} "$INSTDIR\winamp.exe" $R0 ; Get Winamp.exe version information, $R0 = Actual Version
  326. ${if} $R0 != "" ; check if Version info is not empty
  327. ${VersionCompare} $R0 ${MINIMAL_VERSION} $R1 ; $R1 = Result $R1=0 Versions are equal, $R1=1 Version1 is newer, $R1=2 Version2 is newer
  328. ${if} $R1 == "2"
  329. MessageBox MB_OK "Warning: This plug-in requires at least Winamp v${MINIMAL_VERSION} or higher.$\nThe detected version of your Winamp install is: $R0$\n$\nThe Shoutcast Source plug-in may not function correctly with the$\n version of winamp detected.Please update your Winamp client!!$\n"
  330. Abort
  331. ${EndIf}
  332. ${Else}
  333. MessageBox MB_OK "Warning: A valid Winamp install was not detected in the specified path.$\n$\nPlease check the Winamp directory and either install the latest version$\nfrom Winamp.com or choose another directory with a valid Winamp install$\nbefore you can install the Shoutcast Source on your machine."
  334. Abort
  335. ${EndIf}
  336. FunctionEnd
  337. ; Return on top of stack the total size of the selected (installed) sections, formated as DWORD
  338. ; Assumes no more than 256 sections are defined
  339. Function GetInstalledSize
  340. Push $0
  341. Push $1
  342. StrCpy $GetInstalledSize.total 0
  343. ${ForEach} $1 0 256 + 1
  344. StrCpy $0 0
  345. ${if} ${SectionIsSelected} $1
  346. SectionGetSize $1 $0
  347. IntOp $GetInstalledSize.total $GetInstalledSize.total + $0
  348. ${Endif}
  349. ; Error flag is set when an out-of-bound section is referenced
  350. ${if} ${errors}
  351. ${break}
  352. ${Endif}
  353. ${Next}
  354. ClearErrors
  355. Pop $1
  356. Pop $0
  357. IntFmt $GetInstalledSize.total "0x%08X" $GetInstalledSize.total
  358. Push $GetInstalledSize.total
  359. FunctionEnd