!include WordFunc.nsh !insertmacro VersionCompare !include LogicLib.nsh ;-------------------------------- !define VERSION "1.0.1" ; The name of the installer Name "YMEExcelPlugin ${VERSION}" ; The file to write OutFile "YMEExcelPlugin ${VERSION} setup.exe" ; The default installation directory InstallDir "$PROGRAMFILES\Yahoo!\Yahoo! Music Engine\Plugins\Export2Excel" ; Registry key to check for directory (so if you install again, it will ; overwrite the old one automatically) InstallDirRegKey HKLM "Software\YMEPlugins_YMEExcelPlugin" "Install_Dir" Function .onInit Call GetDotNETVersion Pop $0 ${If} $0 == "not found" MessageBox MB_OK|MB_ICONSTOP ".NET runtime library is not installed." Abort ${EndIf} StrCpy $0 $0 "" 1 # skip "v" ${VersionCompare} $0 "2.0" $1 ${If} $1 == 2 MessageBox MB_OK|MB_ICONSTOP ".NET runtime library v2.0 or newer is required. You have $0." Abort ${EndIf} FunctionEnd Function GetDotNETVersion Push $0 Push $1 System::Call "mscoree::GetCORVersion(w .r0, i ${NSIS_MAX_STRLEN}, *i) i .r1" StrCmp $1 "error" 0 +2 StrCpy $0 "not found" Pop $1 Exch $0 FunctionEnd ;-------------------------------- ; Pages Page directory Page instfiles UninstPage uninstConfirm UninstPage instfiles ;-------------------------------- ; The stuff to install Section "Install" ; Set output path to the installation directory. SetOutPath $INSTDIR ; Put file there File "C:\Documents and Settings\Marc\My Documents\Visual Studio 2005\Projects\YMEExcelPlugin\YMEExcelPlugin\bin\Release\*.dll" File "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regasm.exe" ; Register my assembly for COM Interop ExecWait '"$INSTDIR\regasm.exe" /codebase "$INSTDIR\YMEExcelPlugin.dll"' ; Registry keys so that YME can find the plugin WriteRegStr HKLM "Software\Yahoo\YMP\Plugins\YMEExcelPlugin.YMEExcelPlugin" "Name" "Export to Excel" WriteRegStr HKLM "Software\Yahoo\YMP\Plugins\YMEExcelPlugin.YMEExcelPlugin" "Description" "Exports the media database to an Excel worksheet" WriteRegDWORD HKLM "Software\Yahoo\YMP\Plugins\YMEExcelPlugin.YMEExcelPlugin" "Enabled" 1 ; Write the installation path into the registry WriteRegStr HKLM SOFTWARE\YMEPlugins_YMEExcelPlugin "Install_Dir" "$INSTDIR" ; Write the uninstall keys for Windows WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\YMEPlugins_YMEExcelPlugin" "DisplayName" "Yahoo! Music Engine Export to Excel Plugin" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\YMEPlugins_YMEExcelPlugin" "UninstallString" '"$INSTDIR\YMEExcelPlugin_Uninstall.exe"' WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\YMEPlugins_YMEExcelPlugin" "NoModify" 1 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\YMEPlugins_YMEExcelPlugin" "NoRepair" 1 WriteUninstaller "$INSTDIR\YMEExcelPlugin_Uninstall.exe" SectionEnd ; end the section ;-------------------------------- ; Uninstaller Section "Uninstall" ; Unregister my assembly for COM Interop ExecWait '"$INSTDIR\regasm.exe" /unregister "$INSTDIR\YMEExcelPlugin.dll"' ; Remove registry keys DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\YMEPlugins_YMEExcelPlugin" DeleteRegKey HKLM "Software\YMEPlugins_YMEExcelPlugin" DeleteRegKey HKLM "Software\Yahoo\YMP\Plugins\YMEExcelPlugin.YMEExcelPlugin" DeleteRegKey HKCR "YMEExcelPlugin.YMEExcelPlugin" DeleteRegKey HKLM "Software\Classes\YMEExcelPlugin.YMEExcelPlugin" ; Remove files and uninstaller Delete $INSTDIR\YMEExcelPlugin.dll Delete $INSTDIR\Yahoo.MusicEngine.Interop.MediaPlayer.dll Delete $INSTDIR\Yahoo.MusicEngine.Interop.Plugin.dll Delete $INSTDIR\Interop.Excel.dll Delete $INSTDIR\Interop.Office.dll Delete $INSTDIR\Interop.stdole.dll Delete $INSTDIR\Interop.VBIDE.dll Delete $INSTDIR\YMEExcelPlugin.nsi Delete $INSTDIR\regasm.exe Delete "$INSTDIR\YMEExcelPlugin_Uninstall.exe" ; Remove shortcuts, if any ; Delete "$SMPROGRAMS\YMEExcelPlugin\*.*" ; Remove directories used ; RMDir "$SMPROGRAMS\YMEExcelPlugin" ; RMDir "$INSTDIR" SectionEnd