; GoldYoink.nsi ; ; This script will install the GameDev game GoldYoink. ; ; See http://gamedev.sf.net/ for details !include "UpgradeDLL.nsh" ; The name of the installer Name "GoldYoink" ; Output installer EXE name OutFile "GoldYoinkInst.exe" ; Default installation directory InstallDir "$PROGRAMFILES\GoldYoink" ; Remember install location if we installed previously InstallDirRegKey HKLM "SOFTWARE\GoldYoink" "Install_Dir" Page directory Page instfiles UninstPage uninstConfirm UninstPage instfiles ComponentText "Install GoldYoink" Section "Required Components" !define VBFILESDIR "C:\WINDOWS\System32" ; VB Runtime Files CopyVBSysFiles: !insertmacro UpgradeDLL ${VBFILESDIR}\Comcat.dll $SYSDIR\Comcat.dll $SYSDIR !insertmacro UpgradeDLL ${VBFILESDIR}\Msvbvm60.dll $SYSDIR\Msvbvm60.dll $SYSDIR !insertmacro UpgradeDLL ${VBFILESDIR}\Oleaut32.dll $SYSDIR\Oleaut32.dll $SYSDIR !insertmacro UpgradeDLL ${VBFILESDIR}\Olepro32.dll $SYSDIR\Olepro32.dll $SYSDIR !define UPGRADEDLL_NOREGISTER !insertmacro UpgradeDLL ${VBFILESDIR}\Asycfilt.dll $SYSDIR\Asycfilt.dll $SYSDIR !insertmacro UpgradeDLL ${VBFILESDIR}\Stdole2.tlb $SYSDIR\Stdole2.tlb $SYSDIR !undef UPGRADEDLL_NOREGISTER ; Referenced Microsoft Files and ActiveX Controls !insertmacro UpgradeDLL ${VBFILESDIR}\Comdlg32.ocx $SYSDIR\Comdlg32.ocx $SYSDIR !insertmacro UpgradeDLL ${VBFILESDIR}\MSComCtl.ocx $SYSDIR\MSComCtl.ocx $SYSDIR ; Only increase DLL count on new installation IfFileExists $INSTDIR\GDPlay.exe skipAddSharedDLL Push $SYSDIR\Asycfilt.dll Call AddSharedDLL Push $SYSDIR\Comcat.dll Call AddSharedDLL Push $SYSDIR\Msvbvm60.dll Call AddSharedDLL Push $SYSDIR\Oleaut32.dll Call AddSharedDLL Push $SYSDIR\Olepro32.dll Call AddSharedDLL Push $SYSDIR\Stdole2.tlb Call AddSharedDLL ; Referenced Microsoft Files and ActiveX Controls Push $SYSDIR\Comdlg32.ocx Call AddSharedDLL Push $SYSDIR\MSComCtl.ocx Call AddSharedDLL skipAddSharedDLL: IfErrors 0 CopyAppExeFiles MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "An error occurred copying VB runtime files" IDRETRY CopyVBSysFiles MessageBox MB_YESNO|MB_ICONQUESTION "Do you want to continue installing anyway?" IDNO EndInstall ; Set output path to the installation directory. CopyAppExeFiles: SetOutPath $INSTDIR SetOverwrite ifnewer ; Copy Game System files to destination File "C:\Program Files\MyProjects\GameDev\GDPlay.exe" ; Normally GDPlay.EXE is a registered EXE, but this is not a necessary step File "C:\Program Files\MyProjects\BMDXCtls\ReleaseMinDependency\BMDXCtls.dll" RegDLL "$INSTDIR\BMDXCtls.dll" File "C:\Program Files\MyProjects\ScrHost\ReleaseMinDependency\ScrHost.dll" RegDLL "$INSTDIR\ScrHost.dll" IfErrors 0 CopyGameDatFiles MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "An error occurred application files" IDRETRY CopyAppExeFiles MessageBox MB_YESNO|MB_ICONQUESTION "Do you want to continue installing anyway?" IDNO EndInstall ; Copy Game Data files to destination CopyGameDatFiles: File "C:\Program Files\MyProjects\GamePrj\Ladder\*.*" IfErrors 0 CreateGameShortcut MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "An error occurred copying game data files" IDRETRY CopyGameDatFiles MessageBox MB_YESNO|MB_ICONQUESTION "Do you want to continue installing anyway?" IDNO EndInstall CreateGameShortcut: CreateDirectory "$SMPROGRAMS\GoldYoink" CreateShortCut "$SMPROGRAMS\GoldYoink\Play GoldYoink.lnk" "$INSTDIR\GDPlay.exe" '"$INSTDIR\GoldYoink.gdp" /p "$INSTDIR\GoldYoink.vbs"' CreateShortCut "$SMPROGRAMS\GoldYoink\Uninstall GoldYoink.lnk" "$INSTDIR\Uninst.exe" ; Store install location in case install runs again WriteRegStr HKLM "SOFTWARE\GoldYoink" "Install_Dir" "$INSTDIR" ; Add un-install entry for Add/Remove Programs WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GoldYoink" "DisplayName" "GoldYoink (remove only)" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GoldYoink" "UninstallString" '"$INSTDIR\Uninst.exe"' WriteUninstaller "Uninst.exe" IfRebootFlag 0 EndInstall MessageBox MB_YESNO|MB_ICONQUESTION "The system must be rebooted for installation to complete. Reboot now?" IDNO EndInstall Reboot EndInstall: SectionEnd Section "Uninstall" MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "BMDXCtls.dll and ScrHost.dll will be unregistered and removed.$\r$\nIf you use The Scrolling Game Development Kit on this system you will have to re-register those files using regsvr32 or re-install GameDev, unless you have GameDev version 1.4 or later." IDCANCEL EndUninstall DeleteRegKey HKLM "SOFTWARE\GoldYoink" DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GoldYoink" UnRegDLL "$INSTDIR\BMDXCtls.dll" UnRegDLL "$INSTDIR\ScrHost.dll" Delete "$INSTDIR\*.*" RMDir "$INSTDIR" Delete "$SMPROGRAMS\GoldYoink\*.*" RMDir "$SMPROGRAMS\GoldYoink" Push $SYSDIR\Asycfilt.dll Call un.DecrementSharedDLL Push $SYSDIR\Comcat.dll Call un.DecrementSharedDLL Push $SYSDIR\Msvbvm60.dll Call un.DecrementSharedDLL Push $SYSDIR\Oleaut32.dll Call un.DecrementSharedDLL Push $SYSDIR\Olepro32.dll Call un.DecrementSharedDLL Push $SYSDIR\Stdole2.tlb Call un.DecrementSharedDLL Push $SYSDIR\Comdlg32.ocx Call un.DecrementSharedDLL Push $SYSDIR\MSComCtl.ocx Call un.DecrementSharedDLL IfFileExists "$INSTDIR" 0 InstDirOK MessageBox MB_OK "Could not delete $INSTDIR" IDOK 0 InstDirOK: IfFileExists "$SMPROGRAMS\GoldYoink" 0 EndUninstall MessageBox MB_OK "Could not remove shortcut." IDOK 0 EndUninstall: SectionEnd Function AddSharedDLL Exch $R1 Push $R0 ReadRegDword $R0 HKLM Software\Microsoft\Windows\CurrentVersion\SharedDLLs $R1 IntOp $R0 $R0 + 1 WriteRegDWORD HKLM Software\Microsoft\Windows\CurrentVersion\SharedDLLs $R1 $R0 Pop $R0 Pop $R1 FunctionEnd Function un.DecrementSharedDLL Exch $R1 Push $R0 ReadRegDword $R0 HKLM Software\Microsoft\Windows\CurrentVersion\SharedDLLs $R1 StrCmp $R0 "" done IntOp $R0 $R0 - 1 IntCmp $R0 0 rk rk uk rk: DeleteRegValue HKLM Software\Microsoft\Windows\CurrentVersion\SharedDLLs $R1 Goto done uk: WriteRegDWORD HKLM Software\Microsoft\Windows\CurrentVersion\SharedDLLs $R1 $R0 done: Pop $R0 Pop $R1 FunctionEnd