home *** CD-ROM | disk | FTP | other *** search
- '**************************************************************************
- '* MS Test script for Win32s setup program
- '**************************************************************************
-
- ' $DEFINE DEBUG ''Define for script development/debugging
-
- '$INCLUDE 'setupapi.inc'
- '$INCLUDE 'msdetect.inc'
-
- ''Dialog ID's
- CONST WELCOME = 100
- CONST ASKQUIT = 200
- CONST DESTPATH = 300
- CONST EXITFAILURE = 400
- CONST EXITQUIT = 600
- CONST EXITSUCCESS = 700
- CONST OPTIONS = 110
- CONST TOOBIG = 6300
- CONST BADPATH = 6400
- CONST RESTART = 1001
-
- CONST HELPWELCOME = 1000
- CONST VERPATH = 1100
- CONST EXITFAILNOTWIN31 = 1200
- CONST EXITFAILNOTENH = 1300
- CONST EXITFAILNOTPAGING = 1325
- CONST EXITFAILNOTINTEL = 1350
- CONST EXITFAILRUNAPP = 1360
- CONST FREECELLINST = 1400
- CONST FREECELLINSTNOWIN32S = 1450
- CONST FREECELLPATH = 1500
- CONST HELPFREECELL = 1600
-
-
- ''Bitmap ID
- CONST LOGO = 1
-
- GLOBAL DESTLP$ ''LivePix directory
- GLOBAL DESTWING$
- GLOBAL OPTION$
- GLOBAL EXTRACOSTS$
- GLOBAL APPCOSTS$
-
- GLOBAL bInstallDVA%
-
- DECLARE SUB InstallLivePix
- DECLARE SUB InstallWinG
- DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
- DECLARE FUNCTION GetRealWindowsSysDir AS STRING
- DECLARE SUB UpdateWinG32 (szOrig$)
-
- DECLARE FUNCTION OnWin3x LIB "setuphlp.DLL" AS INTEGER
- DECLARE FUNCTION VflatdPresent LIB "setuphlp.DLL" AS INTEGER
- DECLARE FUNCTION GetRealSystemDir LIB "setuphlp.DLL" (szDir$,cbBuf%) AS INTEGER
- DECLARE FUNCTION RestartWindows LIB "setuphlp.DLL" AS INTEGER
- DECLARE FUNCTION IsWin32FileNewer LIB "setuphlp.DLL" (szOrig$,szNew$) AS INTEGER
- DECLARE SUB RenameFilePlease LIB "setuphlp.DLL" (szOrig$,szNew$)
-
- INIT:
- bInstallDVA% = 0
- CUIDLL$ = "mscuistf.dll" '' Custom user interface dll
- HELPPROC$ = "FHelpDlgProc" '' Help dialog procedure
- szOldVer$ ="1.00.000 " '' Reserve space in string for version
-
- ON ERROR GOTO ERRNORMAL
-
- SrcDir$ = GetSymbolValue("STF_SRCDIR")
-
- szInf$ = GetSymbolValue("STF_SRCINFPATH")
- IF szInf$ = "" THEN
- szInf$ = GetSymbolValue("STF_CWDDIR") + "SETUP.inf"
- END IF
- ReadInfFile szInf$
-
- SetBitmap CUIDLL$, LOGO
- SetTitle "My Make Believe Castle Setup Program"
-
- '$IFDEF DEBUG
- i% = SetSizeCheckMode(scmOnIgnore) '' could use scmOff; def = scmOnFatal
- WinDrive$ = MID$(GetWindowsDir, 1, 1)
- IF IsDriveValid(WinDrive$) = 0 THEN
- i% = DoMsgBox("Windows drive ('"+WinDrive$+"') is not a valid drive.", "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
- GOTO QUIT
- END IF
- '$ENDIF ''DEBUG
-
- EXTRACOSTS$ = "ExtraCosts"
- APPCOSTS$ = "AppCosts"
- FOR i% = 1 TO 26 STEP 1
- AddListItem EXTRACOSTS$, "0"
- NEXT i%
-
- WELCOME:
- sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", HELPWELCOME, HELPPROC$)
- IF sz$ = "CONTINUE" THEN
- UIPop 1
- ELSE
- GOSUB ASKQUIT
- GOTO WELCOME
- END IF
-
- GETOPTIONS:
- SetSymbolValue "RadioDefault", "2"
-
- GETOPTIONS1:
- sz$ = UIStartDlg(CUIDLL$, OPTIONS, "FRadioDlgProc", HELPFREECELL, HELPPROC$)
-
- IF sz$ = "CONTINUE" THEN
- OPTION$ = GetSymbolValue("ButtonChecked")
- UIPop 1
- GOTO GETFREEPATH
- ELSEIF sz$ = "REACTIVATE" THEN
- GOTO GETOPTIONS1
- ELSEIF sz$ = "EXIT" THEN
- UIPop 1
- GOSUB ASKQUIT
- GOTO GETOPTIONS1
- END IF
-
- GETFREEPATH:
- DESTLP$ = "C:\MMBC\"
- SetSymbolValue "EditTextIn", DESTLP$
- SetSymbolValue "EditFocus", "END"
-
- GETFREEPATHL1:
- sz$ = UIStartDlg(CUIDLL$, FREECELLPATH, "FEditDlgProc", HELPFREECELL, HELPPROC$)
-
- IF sz$ = "CONTINUE" THEN
- DESTLP$ = GetSymbolValue("EditTextOut")
-
- IF MID$(DESTLP$, LEN(DESTLP$), 1) <> "\" THEN
- DESTLP$ = DESTLP$ + "\"
- END IF
- ''Validate new path.
- IF IsDirWritable(DESTLP$) = 0 THEN
- GOSUB BADPATH
- GOTO GETFREEPATHL1
- END IF
- UIPop 1
-
- GOTO COPYLIVEPIX
- ELSEIF sz$ = "REACTIVATE" THEN
- GOTO GETFREEPATHL1
- ELSEIF sz$ = "EXIT" THEN
- GOSUB ASKQUIT
- GOTO GETFREEPATHL1
- END IF
-
- COPYLIVEPIX:
- InstallWinG
- InstallLivePix
-
- '' check if there is enough free space to install MMBC
- ndrive% = ASC(ucase$(DESTWING$)) - ASC("A") + 1
- ReplaceListItem EXTRACOSTS$, ndrive%, "1024"
- needspace& = GetCopyListCost(EXTRACOSTS$, APPCOSTS$, "")
- IF needspace& > 0 THEN
- ClearCopyList
- GOSUB BADSPACE
- GOTO GETOPTIONS1
- END IF
- CopyFilesInCopyList
- UpdateWinG32 GetRealWindowsSysDir()
- GOSUB ADDGROUP
-
-
- QUIT:
- ON ERROR GOTO ERRQUIT
-
- IF ERR = 0 THEN
- dlg% = EXITSUCCESS
- ELSEIF ERR = STFQUIT THEN
- dlg% = EXITQUIT
- ELSE
- dlg% = EXITFAILURE
- END IF
-
- QUITL1:
- if dlg% = EXITSUCCESS AND bInstallDVA% = 1 then
- sz$ = UIStartDlg(CUIDLL$, RESTART, "FInfoDlgProc", HELPFREECELL, HELPPROC$)
- UIPop 1
- IF sz$ = "CONTINUE" THEN
- rc% = RestartWindows
- ENDIF
- endif
-
- sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
- IF sz$ = "REACTIVATE" THEN
- GOTO QUITL1
- END IF
- UIPop 1
-
-
- END
-
- ERRQUIT:
- i% = DoMsgBox("Setup sources were corrupted!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
- END
-
- ERRNORMAL:
- '' Check if user cancelled setup
- IF ERR = STFQUIT THEN
- GOTO QUIT
- END IF
- RESUME NEXT
-
- BADPATH:
- sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
- IF sz$ = "REACTIVATE" THEN
- GOTO BADPATH
- END IF
- UIPop 1
- RETURN
-
- BADSPACE:
- sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
- IF sz$ = "REACTIVATE" THEN
- GOTO BADSPACE
- END IF
- UIPop 1
- RETURN
-
- ASKQUIT:
- sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
-
- IF sz$ = "EXIT" THEN
- UIPopAll
- ERROR STFQUIT
- ELSEIF sz$ = "REACTIVATE" THEN
- GOTO ASKQUIT
- ELSE
- UIPop 1
- END IF
- RETURN
-
- ADDGROUP:
- CreateProgmanGroup "My Make Believe Castle", "", cmoNone
- ShowProgmanGroup "My Make Believe Castle", 1, cmoNone
- CreateProgmanItem "My Make Believe Castle", "My Make Believe Castle", MakePath(DESTLP$,"mmbc.exe"), "", cmoOverwrite
- RETURN
-
- SUB InstallWinG STATIC
- SrcDir$ = GetSymbolValue("STF_SRCDIR")
- DESTWING$ = GetWindowsSysDir
- AddSectionFilesToCopyList "wing", SrcDir$+"WING", DESTWING$
-
- ' only use DVA on Windows 3.x
- '
- IF OnWin3x() = 1 THEN
- AddSectionFilesToCopyList "dva", SrcDir$+"WING", DESTWING$
- IF VflatdPresent() = 0 THEN
- CreateSysIniKeyValue GetWindowsDir + "system.ini", "386Enh", "device", GetWindowsSysDir+"dva.386", cmoOverwrite
- bInstallDVA% = 1
- END IF
- END IF
- DESTWING$ = GetRealWindowsSysDir
-
- AddSectionFilesToCopyList "wing32", SrcDir$+"WING", DESTWING$
- Dest1$ = MakePath(DESTWING$,"wing32.dll")
- Dest2$ = MakePath(DESTWING$,"wing32.xxx")
- RenameFilePlease Dest1$,Dest2$
-
- END SUB
- '**
- '** Purpose:
- '** Builds the copy list and performs all installation operations.
- '** Arguments:
- '** none.
- '** Returns:
- '** none.
- '*************************************************************************
- SUB InstallLivePix STATIC
-
- SrcDir$ = GetSymbolValue("STF_SRCDIR")
- CreateDir DESTLP$, cmoNone
- CreateDir DESTLP$+"SAVE", cmoNone
-
- CreateIniKeyValue GetWindowsDir+"MMBC.INI", "Dirs", "BMPS", SrcDir$, cmoOverwrite
- CreateIniKeyValue GetWindowsDir+"MMBC.INI", "Dirs", "MIDI", SrcDir$+"MIDI", cmoOverwrite
- CreateIniKeyValue GetWindowsDir+"MMBC.INI", "Dirs", "SAVE", DESTLP$+"SAVE", cmoOverwrite
- AddSectionFilesToCopyList "Files", SrcDir$, DESTLP$
- IF OPTION$ = "1" THEN
- AddSectionFilesToCopyList "BMPFiles", SrcDir$, DESTLP$
- AddSectionFilesToCopyList "MIDIFiles", SrcDir$+"MIDI", DESTLP$+"MIDI"
- CreateIniKeyValue GetWindowsDir+"MMBC.INI", "Dirs", "BMPS", DESTLP$, cmoOverwrite
- CreateIniKeyValue GetWindowsDir+"MMBC.INI", "Dirs", "MIDI", DESTLP$+"MIDI", cmoOverwrite
- ELSE
- AddSectionFilesToCopyList "RemBMPFiles", SrcDir$, DESTLP$
- AddSectionFilesToCopyList "RemMIDIFiles", SrcDir$+"MIDI", DESTLP$+"MIDI"
- ENDIF
- END SUB
-
-
- '**
- '** Purpose:
- '** Appends a file name to the end of a directory path,
- '** inserting a backslash character as needed.
- '** Arguments:
- '** szDir$ - full directory path (with optional ending "\")
- '** szFile$ - filename to append to directory
- '** Returns:
- '** Resulting fully qualified path name.
- '*************************************************************************
- FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
- IF szDir$ = "" THEN
- MakePath = szFile$
- ELSEIF szFile$ = "" THEN
- MakePath = szDir$
- ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
- MakePath = szDir$ + szFile$
- ELSE
- MakePath = szDir$ + "\" + szFile$
- END IF
- END FUNCTION
-
-
- FUNCTION GetRealWindowsSysDir STATIC AS STRING
- szBuf$ = string$(260, 32)
- cbBuf% = GetRealSystemDir(szBuf$, 260)
- IF cbBuf% = 0 THEN
- ERROR STFERR
- ELSE
- IF cbBuf% > 259 THEN
- res% = DoMsgBox("Buffer Overflow", "MS-Setup Error", MB_ICONHAND+MB_OK)
- ERROR STFERR
- END IF
- szBuf$ = RTRIM$(szBuf$)
- IF MID$(szBuf$, 1, 1) = "\" THEN
- szBuf$ = MID$(CURDIR$, 1, 2) + szBuf$
- ELSEIF MID$(szBuf$, 2, 1) <> ":" THEN
- szBuf$ = MID$(CURDIR$, 1, 3) + szBuf$
- END IF
- IF MID$(szBuf$, LEN(szBuf$), 1) <> "\" THEN
- szBuf$ = szBuf$ + "\"
- END IF
- GetRealWindowsSysDir = szBuf$
- END IF
-
- szBuf$ = ""
- END FUNCTION
-
- SUB UpdateWinG32 (szOrig$) STATIC
- '
- ' Here we check the version ourselves of wing32.dll, since
- ' we can't get version checking for Win32 apps from Win16
- '
- FileNew$ = MakePath(szOrig$, "wing32.dll")
- FileOrig$ = MakePath(szOrig$, "wing32.xxx")
- IF IsWin32FileNewer( FileOrig$, FileNew$ ) THEN
- RemoveFile FileOrig$, cmoForce
- ELSE
- RemoveFile FileNew$, cmoForce ' get rid of new file
- RenameFilePlease FileOrig$,FileNew$ ' put back old file
- END IF
- END SUB
-
-