home *** CD-ROM | disk | FTP | other *** search
- '' ---------------------------------------------------------------------
- ''
- '' Sherman's Lagoon Setup
- ''
- '' ---------------------------------------------------------------------
-
- '' '$define DEBUG ''Define for script development/debugging
-
- '' '$define LOGFILE
-
- '' ---------------------------------------------------------------------
-
- '$include 'setupapi.inc'
- '$include 'msdetect.inc'
-
- '' ---------------------------------------------------------------------
-
- '' Resource ID's
- CONST IDICN_SETUP = 6000
- CONST IDBMP_LOGO = 6100
-
- '' Custom Dialog IDs
- CONST IDDLG_WELCOME = 100
- CONST IDDLG_ASKQUIT = 200
- CONST IDDLG_DESTPATH = 300
- CONST IDDLG_EXITQUIT = 400
- CONST IDDLG_EXITSUCCESS = 500
- CONST IDDLG_NODISKSPACE = 600
- CONST IDDLG_SELECTOPTIONS = 700
- CONST IDDLG_PLEASEWAIT = 800
-
- '' Custom user interface dll
- CONST CUIDLL$ = "cui.dll"
-
- '' ---------------------------------------------------------------------
-
- '' Default destination directory.
- GLOBAL DEST$
-
- '' Windows version value.
- GLOBAL WinVer%
-
- '' List of extra costs to add per drive
- CONST szExtraCosts$ = "ExtraCosts"
- CONST szCosts$ = "Costs"
-
- '' Options
- GLOBAL OptMakeDefault%
-
- '' Section names, case sensitive: any files without a section go under "Files"
- CONST ProgramKey$ = "lagoon"
-
- '' ---------------------------------------------------------------------
-
- '' Return values from GetWindowsVersion()
- CONST WINVER_WIN31 = 1
- CONST WINVER_WIN40 = 2
- CONST WINVER_WFW = 3
- CONST WINVER_WOW = 4
- CONST WINVER_NT = 5
- CONST WINVER_32S = 6
- CONST WINVER_ERROR = -1
-
- '$ifdef WIN_FILE_FUNCTIONS
- '' _lopen modes and flags.
- CONST READ = 0
- CONST WRITE = 1
- CONST READ_WRITE = 2
- CONST OF_SHARE_COMPAT = 0
- CONST OF_SHARE_DENY_NONE = 64
- CONST OF_SHARE_DENY_READ = 48
- CONST OF_SHARE_DENY_WRITE = 32
- CONST OF_SHARE_EXCLUSIVE = 16
-
- '' _llseek origin values.
- CONST SEEK_SET = 0
- CONST SEEK_CUR = 1
- CONST SEEK_END = 2
-
- '' Windows functions
- DECLARE FUNCTION _lopen LIB "kernel" (szFile$, iOpenMode%) AS INTEGER
- DECLARE FUNCTION _lcreat LIB "kernel" (szFile$, iCreateMode) AS INTEGER
- DECLARE FUNCTION _lclose LIB "kernel" (handle%) AS INTEGER
- DECLARE FUNCTION _llseek LIB "kernel" (handle%, LONG, int) AS LONG
- DECLARE FUNCTION _lread LIB "kernel" (handle%, void _huge*, UINT) AS INTEGER
- DECLARE FUNCTION _lwrite LIB "kernel" (handle%, const void _huge*, UINT) AS INTEGER
- '$endif
-
- '' My DLL functions
- DECLARE FUNCTION CountSectionCost LIB "cui.dll" (uDestDisk%, section$, keylistname$) AS LONG
- DECLARE FUNCTION IsStringInFile LIB "cui.dll" (lpszFilename$, lpszString$) AS INTEGER
- DECLARE FUNCTION GetGroupList LIB "cui.dll" (lpszSymName$) AS INTEGER
- DECLARE FUNCTION GetWindowsVersion LIB "cui.dll" AS INTEGER
- ''DECLARE FUNCTION MoveFile LIB "cui.dll" (pszSrc$, pszDst$) AS INTEGER
-
- '' Local function declarations
- DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
- DECLARE SUB BuildCopyList (_Option%)
- DECLARE SUB DoInstall
- DECLARE SUB AskQuit
- DECLARE FUNCTION BytesPerOption (_Opttion%) AS LONG
-
- '' ---------------------------------------------------------------------
-
- '' Lets do an installation ...
- INIT:
- ON ERROR GOTO QUIT
-
- '' Some standard setup stuff
- SetBitmap CUIDLL$, IDBMP_LOGO
- SetTitle "" ''Already displayed as a bmp in the window --> "Sherman's Lagoon Setup"
-
- '' Make a complete path to the INF file
- szInf$ = GetSymbolValue("STF_SRCINFPATH")
- IF szInf$ = "" THEN
- szInf$ = GetSymbolValue("STF_CWDDIR") + "LAGOON.INF"
- END IF
-
- '' Read in the INF file
- ReadInfFile szInf$
-
- '' Screen savers go in either the "windows" or "windows\system" directory.
- WinVer% = GetWindowsVersion()
- if WinVer% = WINVER_WIN31 OR WinVer% = WINVER_WFW OR WinVer% = WINVER_32S THEN
- DEST$ = GetWindowsDir() '' Windows 3.1
- ELSE
- DEST$ = GetWindowsSysDir() '' Windows 95, Windows NT
- END IF
-
- '' Default: select all options
- OptMakeDefault% = 1
-
- '$ifdef DEBUG
- i% = SetSizeCheckMode(scmOnIgnore)
- '$else
- i% = SetSizeCheckMode(scmOnFatal)
- '$endif
-
- '$ifdef LOGFILE
- OpenLogFile MakePath$(DEST$, "lagoon.log"), 0
- '$endif
-
- WELCOME:
- sz$ = UIStartDlg(CUIDLL$, IDDLG_WELCOME, "FDlgProc", 0, "")
- IF sz$ = "CONTINUE" THEN
- UIPop 1
- ELSEIF sz$ = "REACTIVATE" THEN
- GOTO WELCOME
- ELSE
- ASKQUIT
- GOTO WELCOME
- END IF
-
-
- SELECTOPTIONS:
- sz$ = UIStartDlg(CUIDLL$, IDDLG_PLEASEWAIT, "FModelessDlgProc", 0, "")
-
- '' Screen savers
- Bytes& = BytesPerOption&(1)
- SetSymbolValue "Text1", STR$(Bytes& / 1024) + "K"
-
- '' Check the options
- SetSymbolValue "CheckItemsIn", ""
- IF OptMakeDefault% = 1 THEN
- AddListItem "CheckItemsIn", "ON"
- ELSE
- AddListItem "CheckItemsIn", "OFF"
- END IF
-
- UIPop 1
-
- SELECTOPTIONS1:
- '' Run the dialog
- sz$ = UIStartDlg(CUIDLL$, IDDLG_SELECTOPTIONS, "FDlgProc", 0, "")
- IF sz$ = "CONTINUE" OR sz$ = "BACK" THEN
-
- '' Retrieve the options
- IF GetListItem("CheckItemsOut", 1) = "ON" THEN
- OptMakeDefault% = 1
- ELSE
- OptMakeDefault% = 0
- END IF
-
- UIPop 1
-
- IF sz$ = "BACK" THEN
- GOTO WELCOME
- END IF
-
- ELSEIF sz$ = "REACTIVATE" THEN
- GOTO SELECTOPTIONS '' Recalc sizes
- ELSE
- ASKQUIT
- GOTO SELECTOPTIONS
- END IF
-
- '' Like it says
- BuildCopyList 1
-
- RECALC:
- '' Check the amount of space needed
- StillNeed& = GetCopyListCost("ExtraCostsList", "CostCostsList", "NeededCostsList")
- IF StillNeed& <> 0 THEN
- SPACE_CHECK_DLG:
- '' Space required
- SetSymbolValue "Text1", STR$(StillNeed& / 1024) + "K"
-
- '' Space available
- Bytes& = GetFreeSpaceForDrive(Mid$(DEST$, 1, 1))
- SetSymbolValue "Text2", STR$(Bytes& / 1024) + "K"
-
- SPACE_CHECK_DLG1:
- sz$ = UIStartDlg(CUIDLL$, IDDLG_NODISKSPACE, "FDlgProc", 0, "")
- IF sz$ = "CONTINUE" THEN
- UIPop 1
- GOTO SELECTOPTIONS
- ELSEIF sz$ = "REACTIVATE" THEN
- GOTO RECALC
- ELSE
- ASKQUIT
- GOTO SPACE_CHECK_DLG
- END IF
- ENDIF
-
- '' Perform the installation
- DoInstall
-
-
- QUIT:
- IF ERR = 0 THEN
- dlg% = IDDLG_EXITSUCCESS
- ELSEIF ERR = STFQUIT THEN
- dlg% = IDDLG_EXITQUIT
- ELSE
- dlg% = IDDLG_EXITQUIT
- END IF
-
- QUITL1:
- sz$ = UIStartDlg(CUIDLL$, dlg%, "FDlgProc", 0, "")
- IF sz$ = "REACTIVATE" THEN
- GOTO QUITL1
- END IF
- UIPop 1
-
-
- '$ifdef LOGFILE
- CloseLogFile
- '$endif
-
- END
-
- '' ---------------------------------------------------------------------
-
- SUB BuildCopyList (_Option%) STATIC
-
- SrcDir$ = GetSymbolValue("STF_SRCDIR")
- ClearCopyList
-
- '' Add everything that has the given key string.
- AddSectionFilesToCopyList ProgramKey$, SrcDir$, DEST$
-
- END SUB
-
- '' ---------------------------------------------------------------------
-
- '**
- '** Count the number of bytes needed to copy the given
- '** section(s) to the users disk.
- '**
-
- FUNCTION BytesPerOption (_Option%) STATIC AS LONG
-
- BuildCopyList 1
-
- '' Zero out the variables.
- SetSymbolValue szExtraCosts$, ""
- FOR i% = 1 TO 26 STEP 1
- AddListItem szExtraCosts$, "0"
- NEXT i%
-
- '' Add extra cost to Windows drive for ini additions.
- ''szWinDrive$ = MID$(GetWindowsDir, 1, 1)
- ''ndrive% = ASC(ucase$(szWinDrive$)) - ASC("A") + 1
- ''ReplaceListItem szExtraCosts$, ndrive%, "1024"
-
- '' Compute the space
- StillNeed& = GetCopyListCost(szExtraCosts$, szCosts$, "")
-
- '' Add up the space required
- cost& = 0
- FOR i% = 1 TO 26 STEP 1
- TheCost& = VAL(GetListItem(szCosts$, i%))
- IF TheCost& > 0 THEN
- cost& = cost& + TheCost&
- END IF
- NEXT i%
-
- BytesPerOption = cost&
-
- END FUNCTION
-
- '' ---------------------------------------------------------------------
-
- '**
- '** Purpose:
- '** Builds the copy list and performs all installation operations.
- '** Arguments:
- '** none.
- '** Returns:
- '** none.
-
- SUB DoInstall STATIC
-
- SrcDir$ = GetSymbolValue("STF_SRCDIR")
- CreateDir DEST$, cmoNone
-
- ClearBillboardList
- CopyFilesInCopyList
-
- sz$ = UIStartDlg(CUIDLL$, IDDLG_PLEASEWAIT, "FModelessDlgProc", 0, "")
-
- '' The default disk file name.
- szSaverName$ = "Lagoon.scr"
-
- '' If under windows 95 change disk file name of the screen saver to
- '' it's descriptive name.
- IF WinVer% = WINVER_WIN40 THEN
- szSaverName$ = "Sherman's Lagoon.scr"
- szSrc$ = MakePath$(DEST$, "lagoon.scr")
- szDst$ = """" + szSaverName$ + """"
-
- '' Rename to it's descriptive name.
- SHELL "del " + """" + MakePath$(DEST$, szSaverName$) + """"
- SHELL "ren " + szSrc$ + " " + szDst$
-
- '' Change to the 8.3 format so it appears as default screen saver.
- szSaverName$ = "SHERMA~1.SCR"
- END IF
-
- '' Make the screen saver current.
- IF OptMakeDefault% <> 0 THEN
- inifile$ = MakePath$(GetWindowsDir(), "system.ini")
- scrsaver$ = MakePath$(DEST$, szSaverName$)
- CreateIniKeyValue inifile$, "boot", "SCRNSAVE.EXE", scrsaver$, cmoOverwrite
- END IF
-
- UIPop 1
-
- 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
-
- '' ---------------------------------------------------------------------
-
- '**
- '** Ask the user if they want to quit.
- '**
-
- SUB AskQuit STATIC
-
- _ASKQUIT:
- sz$ = UIStartDlg(CUIDLL$, IDDLG_ASKQUIT, "FDlgProc", 0, "")
-
- IF sz$ = "EXIT" THEN
- UIPopAll
- ERROR STFQUIT
- ELSEIF sz$ = "REACTIVATE" THEN
- GOTO _ASKQUIT
- ELSE
- UIPop 1
- END IF
-
- END SUB
-
- '' ---------------------------------------------------------------------
-