!if "@ARCH@" == x86 !define arch_x86 !endif !if "@ARCH@" == i686-w64-mingw32.shared !define arch_x86 !endif !if "@ARCH@" == x86_64 !define arch_x64 !endif !if "@ARCH@" == x86_64-w64-mingw32.shared !define arch_x64 !endif !if "@CMAKE_BUILD_TYPE@" == Debug !define debug !endif !if "@BUILD_WITH_QT6@" == "ON" !define with_qt6 !endif !ifdef debug !define PRODUCT_NAME "Strawberry Music Player Debug WASAPI plugin" !define PRODUCT_NAME_SHORT "StrawberryWASAPI" !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME_SHORT}Debug" !ifdef arch_x86 !define PRODUCT_INSTALL_DIR "$PROGRAMFILES\Strawberry Music Player Debug" !endif !ifdef arch_x64 !define PRODUCT_INSTALL_DIR "$PROGRAMFILES64\Strawberry Music Player Debug" !endif !else !define PRODUCT_NAME "Strawberry Music Player WASAPI plugin" !define PRODUCT_NAME_SHORT "StrawberryWASAPI" !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME_SHORT}" !ifdef arch_x86 !define PRODUCT_INSTALL_DIR "$PROGRAMFILES\Strawberry Music Player" !endif !ifdef arch_x64 !define PRODUCT_INSTALL_DIR "$PROGRAMFILES64\Strawberry Music Player" !endif !endif !define PRODUCT_VERSION_MAJOR @STRAWBERRY_VERSION_MAJOR@ !define PRODUCT_VERSION_MINOR @STRAWBERRY_VERSION_MINOR@ !define PRODUCT_VERSION_PATCH @STRAWBERRY_VERSION_PATCH@ !define PRODUCT_DISPLAY_VERSION "@STRAWBERRY_VERSION_PACKAGE@" !define PRODUCT_DISPLAY_VERSION_SHORT "@STRAWBERRY_VERSION_PACKAGE@" !define PRODUCT_PUBLISHER "Jonas Kvinge" !define PRODUCT_WEB_SITE "https://www.strawberrymusicplayer.org/" !define PRODUCT_UNINST_ROOT_KEY "HKLM" SetCompressor /SOLID lzma !addplugindir nsisplugins !include "MUI2.nsh" !include "FileAssociation.nsh" !include "Capabilities.nsh" !include LogicLib.nsh !include x64.nsh !define MUI_ICON "strawberry.ico" !define MUI_COMPONENTSPAGE_SMALLDESC ; Installer pages !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH ; Uninstaller pages !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_UNPAGE_FINISH !insertmacro MUI_LANGUAGE "English" ;first language is the default language Name "${PRODUCT_NAME}" !ifdef arch_x86 !ifdef debug !ifdef with_qt6 OutFile "${PRODUCT_NAME_SHORT}Setup-${PRODUCT_DISPLAY_VERSION}-Qt6-Debug-x86.exe" !else OutFile "${PRODUCT_NAME_SHORT}Setup-${PRODUCT_DISPLAY_VERSION}-Debug-x86.exe" !endif !else !ifdef with_qt6 OutFile "${PRODUCT_NAME_SHORT}Setup-${PRODUCT_DISPLAY_VERSION}-Qt6-x86.exe" !else OutFile "${PRODUCT_NAME_SHORT}Setup-${PRODUCT_DISPLAY_VERSION}-x86.exe" !endif !endif !endif !ifdef arch_x64 !ifdef debug !ifdef with_qt6 OutFile "${PRODUCT_NAME_SHORT}Setup-${PRODUCT_DISPLAY_VERSION}-Qt6-Debug-x64.exe" !else OutFile "${PRODUCT_NAME_SHORT}Setup-${PRODUCT_DISPLAY_VERSION}-Debug-x64.exe" !endif !else !ifdef with_qt6 OutFile "${PRODUCT_NAME_SHORT}Setup-${PRODUCT_DISPLAY_VERSION}-Qt6-x64.exe" !else OutFile "${PRODUCT_NAME_SHORT}Setup-${PRODUCT_DISPLAY_VERSION}-x64.exe" !endif !endif !endif InstallDir "${PRODUCT_INSTALL_DIR}" ; Get the path where Strawberry was installed previously and set it as default path InstallDirRegKey ${PRODUCT_UNINST_ROOT_KEY} ${PRODUCT_UNINST_KEY} "UninstallString" ShowInstDetails show ShowUnInstDetails show RequestExecutionLevel admin ; Check for previous installation, and call the uninstaller if any Function CheckPreviousInstall ReadRegStr $R0 ${PRODUCT_UNINST_ROOT_KEY} ${PRODUCT_UNINST_KEY} "UninstallString" StrCmp $R0 "" done MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \ "${PRODUCT_NAME} 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 ExecWait '$R0' ; Do not copy the uninstaller to a temp file done: FunctionEnd Function .onInit !insertmacro MUI_LANGDLL_DISPLAY Call CheckPreviousInstall FunctionEnd Section "Gstreamer wasapi plugin" gstreamer-wasapi-plugin SetOutPath "$INSTDIR\gstreamer-plugins" File "/oname=libgstwasapi.dll" "gstreamer-plugins\libgstwasapi.dll" SectionEnd Section "Uninstaller" ; Create uninstaller WriteUninstaller "$INSTDIR\Uninstall-WASAPI.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "${PRODUCT_NAME}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\Uninstall-WASAPI.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\strawberry.ico" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_DISPLAY_VERSION}" WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "VersionMajor" "${PRODUCT_VERSION_MAJOR}" WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "VersionMinor" "${PRODUCT_VERSION_MINOR}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}" SectionEnd Section "Uninstall" Delete "$INSTDIR\gstreamer-plugins\libgstwasapi.dll" Delete "$INSTDIR\Uninstall-WASAPI.exe" ; Remove the entry from 'installed programs list' DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" SectionEnd