home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1997 July
/
Chip_1997-07_cd.bin
/
tema
/
mattes
/
ip
/
ip25
/
disk1
/
ip.mst
< prev
next >
Wrap
Text File
|
1994-07-31
|
17KB
|
603 lines
'**************************************************************************
'* MSSetup Toolkit Sample 1
'**************************************************************************
'$DEFINE DEBUG ''Define for script development/debugging
'$INCLUDE 'setupapi.inc'
'$INCLUDE 'msdetect.inc'
'$INCLUDE 'msregdb.inc'
''Dialog ID's
CONST CUSTINST = 3
CONST WELCOME = 100
CONST ASKQUIT = 200
CONST DESTPATH = 300
CONST EXITFAILURE = 400
CONST EXITQUIT = 600
CONST EXITSUCCESS = 700
CONST OPTIONS = 800
CONST OPTIONS1 = 800
CONST OPTIONS2 = 800
CONST APPHELP = 900
CONST TOOBIG = 6300
CONST BADPATH = 6400
CONST PROGRAM = 451
CONST COMPLEX = 452
CONST DEMOS = 453
CONST EXPERIMENTS = 454
CONST INTERACTIONS = 455
CONST APPFILES = 1
CONST DEMOFILES = 2
CONST INTERACTIONFILES = 3
''Bitmap ID
CONST LOGO = 1
GLOBAL DEST$ ''Default destination directory.
GLOBAL WINDRIVE$ ''Windows drive letter.
GLOBAL OPTCUR$ ''Option selection from option dialog.
GLOBAL OPT1OPT$ ''Option selection from DemoFiles option dialog.
GLOBAL OPT2OPT$ ''Option selection from InteractionFiles option dialog.
''CustInst list symbol names
GLOBAL APPNEEDS$ ''Option list costs per drive
GLOBAL OPT1NEEDS$
GLOBAL OPT2NEEDS$
GLOBAL EXTRACOSTS$ ''List of extra costs to add per drive
GLOBAL BIGLIST$ ''List of option files cost calc results (boolean)
''Dialog list symbol names
GLOBAL CHECKSTATES$
GLOBAL STATUSTEXT$
GLOBAL DRIVETEXT$
DECLARE SUB Install
DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
DECLARE SUB AddOptFilesToCopyList (ftype%)
DECLARE SUB RecalcOptFiles (ftype%)
DECLARE SUB RecalcPath
DECLARE SUB SetDriveStatus
INIT:
CUIDLL$ = "mscuistf.dll" ''Custom user interface dll
HELPPROC$ = "FHelpDlgProc" ''Help dialog procedure
SetBitmap CUIDLL$, LOGO
SetTitle "Interactive Physics 2.5 Installer"
szInf$ = GetSymbolValue("STF_SRCINFPATH")
IF szInf$ = "" THEN
szInf$ = GetSymbolValue("STF_CWDDIR") + "ip.INF"
END IF
ReadInfFile szInf$
OPTCUR$ = "1"
DEST$ = "C:\ip25"
'$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
''CustInst list symbols
CHECKSTATES$ = "CheckItemsState"
STATUSTEXT$ = "StatusItemsText"
DRIVETEXT$ = "DriveStatusText"
FOR i% = 1 TO 3 STEP 1
AddListItem CHECKSTATES$, "ON"
NEXT i%
FOR i% = 1 TO 3 STEP 1
AddListItem STATUSTEXT$, ""
NEXT i%
FOR i% = 1 TO 7 STEP 1
AddListItem DRIVETEXT$, ""
NEXT i%
ReplaceListItem DRIVETEXT$, 7, DEST$
''Disk cost list symbols
APPNEEDS$ = "AppNeeds"
OPT1NEEDS$ = "Opt1Needs"
OPT2NEEDS$ = "Opt2Needs"
EXTRACOSTS$ = "ExtraCosts"
BIGLIST$ = "BigList"
FOR i% = 1 TO 3 STEP 1
AddListItem BIGLIST$, ""
NEXT i%
FOR i% = 1 TO 26 STEP 1
AddListItem EXTRACOSTS$, "0"
NEXT i%
''File Option Variables
OPT1OPT$ = "1"
OPT2OPT$ = "1"
RecalcPath
SetDriveStatus
WELCOME:
sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$)
IF sz$ = "CONTINUE" THEN
UIPop 1
ELSE
GOSUB ASKQUIT
GOTO WELCOME
END IF
OPTION:
SetSymbolValue "RadioDefault", OPTCUR$
OPTL1:
sz$ = UIStartDlg(CUIDLL$, OPTIONS, "FRadioDlgProc", APPHELP, HELPPROC$)
OPTCUR$ = GetSymbolValue("ButtonChecked")
IF sz$ = "CONTINUE" THEN
UIPop(1)
ELSEIF sz$ = "REACTIVATE" THEN
GOTO OPTL1
ELSEIF sz$ = "BACK" THEN
UIPop(1)
GOTO WELCOME
ELSE
GOSUB ASKQUIT
GOTO OPTION
END IF
IF OPTCUR$ = "1" THEN
GETPATH:
SetSymbolValue "EditFocus", "END"
GETPATHL1:
SetSymbolValue "EditTextIn", DEST$
sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
DEST$ = GetSymbolValue("EditTextOut")
IF sz$ = "CONTINUE" THEN
DEST$ = GetSymbolValue("EditTextOut")
IF IsDirWritable(DEST$) = 0 THEN
GOSUB BADPATH
GOTO GETPATHL1
END IF
''Install only if it will fit.
SetDriveStatus
RecalcOptFiles APPFILES
RecalcOptFiles DEMOFILES
RecalcOptFiles INTERACTIONFILES
FOR i% = 1 TO 3 STEP 1
IF GetListItem(BIGLIST$, i%) <> "" THEN
GOSUB TOOBIG
GOTO GETPATH
END IF
NEXT i%
UIPop 1
ELSEIF sz$ = "REACTIVATE" THEN
GOTO GETPATHL1
ELSEIF sz$ = "BACK" THEN
UIPop 1
GOTO OPTION
ELSE
GOSUB ASKQUIT
GOTO GETPATH
END IF
GOTO FINI
ELSE
CUSTINST:
sz$ = UIStartDlg(CUIDLL$, CUSTINST, "FCustInstDlgProc", APPHELP, HELPPROC$)
IF sz$ = "CONTINUE" THEN
''Install only if it will fit.
SetDriveStatus
RecalcOptFiles APPFILES
RecalcOptFiles DEMOFILES
RecalcOptFiles INTERACTIONFILES
FOR i% = 1 TO 3 STEP 1
IF GetListItem(BIGLIST$, i%) <> "" THEN
GOSUB TOOBIG
GOTO CUSTINST
END IF
NEXT i%
UIPop 1
GOTO FINI
ELSEIF sz$ = "PATH" THEN
GETPATH2:
SetSymbolValue "EditFocus", "END"
GETPATH2L1:
SetSymbolValue "EditTextIn", DEST$
sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
IF sz$ = "CONTINUE" THEN
DEST$ = GetSymbolValue("EditTextOut")
IF IsDirWritable(DEST$) = 0 THEN
GOSUB BADPATH
GOTO GETPATH2L1
END IF
UIPop 1
''Truncate display if too long.
IF LEN(DEST$) > 23 THEN
ReplaceListItem DRIVETEXT$, 7, MID$(DEST$, 1, 23)+"..."
ELSE
ReplaceListItem DRIVETEXT$, 7, DEST$
END IF
''Recalc if path changed.
IF (olddest$ <> DEST$) AND (olddest$ <> DEST$+"\") AND (olddest$+"\" <> DEST$) THEN
RecalcPath
SetDriveStatus
END IF
olddest$ = ""
GOTO CUSTINST
ELSEIF sz$ = "REACTIVATE" THEN
DEST$ = GetSymbolValue("EditTextOut")
GOTO GETPATH2L1
ELSEIF sz$ = "BACK" THEN
UIPop 1
GOTO GETPATH2L1
ELSE
GOSUB ASKQUIT
GOTO GETPATH2
END IF
ELSEIF sz$ = "CHK1" THEN
RecalcOptFiles APPFILES
SetDriveStatus
GOTO CUSTINST
ELSEIF sz$ = "CHK2" THEN
RecalcOptFiles DEMOFILES
SetDriveStatus
GOTO CUSTINST
ELSEIF sz$ = "CHK3" THEN
RecalcOptFiles INTERACTIONFILES
SetDriveStatus
GOTO CUSTINST
ELSEIF sz$ = "BTN2" THEN
GOTO DEMOFILES
ELSEIF sz$ = "BTN3" THEN
GOTO INTERACTIONFILES
ELSEIF sz$ = "REACTIVATE" THEN
GOTO CUSTINST
ELSEIF sz$ = "BACK" THEN
UIPop 1
GOTO OPTION
ELSE
GOSUB ASKQUIT
GOTO CUSTINST
END IF
END IF
FINI:
Install
QUIT:
ON ERROR GOTO ERRQUIT
IF ERR = 0 THEN
dlg% = EXITSUCCESS
ELSEIF ERR = STFQUIT THEN
dlg% = EXITQUIT
ELSE
dlg% = EXITFAILURE
END IF
QUITL1:
sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
IF sz$ = "REACTIVATE" THEN
GOTO QUITL1
END IF
UIPop 1
END
ERRQUIT:
i% = DoMsgBox("Setup sources were corrupted, call 555-1212!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
END
BADPATH:
sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
IF sz$ = "REACTIVATE" THEN
GOTO BADPATH
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
DEMOFILES:
SetSymbolValue "RadioDefault", OPT1OPT$
OPT1L1:
sz$ = UIStartDlg(CUIDLL$, OPTIONS1, "FRadioDlgProc", APPHELP, HELPPROC$)
newopt$ = GetSymbolValue("ButtonChecked")
IF sz$ = "CONTINUE" THEN
UIPop 1
IF newopt$ <> OPT1OPT$ THEN
OPT1OPT$ = newopt$
END IF
newopt$ = ""
GOTO CUSTINST
ELSEIF sz$ = "REACTIVATE" THEN
GOTO OPT1L1
ELSEIF sz$ = "EXIT" THEN
GOSUB ASKQUIT
GOTO OPT1L1
ELSE
UIPop 1
newopt$ = ""
GOTO CUSTINST
END IF
INTERACTIONFILES:
SetSymbolValue "RadioDefault", OPT2OPT$
OPT2L1:
sz$ = UIStartDlg(CUIDLL$, OPTIONS2, "FRadioDlgProc", APPHELP, HELPPROC$)
newopt$ = GetSymbolValue("ButtonChecked")
IF sz$ = "CONTINUE" THEN
UIPop 1
IF newopt$ <> OPT2OPT$ THEN
OPT2OPT$ = newopt$
END IF
newopt$ = ""
GOTO CUSTINST
ELSEIF sz$ = "REACTIVATE" THEN
GOTO OPT2L1
ELSEIF sz$ = "EXIT" THEN
GOSUB ASKQUIT
GOTO OPT2L1
ELSE
UIPop 1
newopt$ = ""
GOTO CUSTINST
END IF
TOOBIG:
sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
IF sz$ = "REACTIVATE" THEN
GOTO TOOBIG
END IF
UIPop 1
RETURN
'**
'** Purpose:
'** Builds the copy list and performs all installation operations.
'** Arguments:
'** none.
'** Returns:
'** none.
'*************************************************************************
SUB Install STATIC
SrcDir$ = GetSymbolValue("STF_SRCDIR")
CreateDir DEST$, cmoNone
OpenLogFile MakePath(DEST$, "LOGFILE.OUT"), 0
WriteToLogFile ""
WriteToLogFile " User chose as destination directory: '" + DEST$ + "'"
WriteToLogFile " User chose option: '" + OPTCUR$ + "'"
WriteToLogFile ""
WriteToLogFile "May have had to create the directory: " + DEST$
WriteToLogFile ""
IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
AddSectionFilesToCopyList "AppFiles", SrcDir$, DEST$
ENDIF
IF GetListItem(CHECKSTATES$, DEMOFILES) = "ON" THEN
AddSectionFilesToCopyList "DemoFiles", SrcDir$, DEST$
ENDIF
IF GetListItem(CHECKSTATES$, INTERACTIONFILES) = "ON" THEN
AddSectionFilesToCopyList "InteractionFiles", SrcDir$, DEST$
ENDIF
'' AddSectionKeyFileToCopyList "Options", OPTCUR$, SrcDir$, DEST$
CopyFilesInCopyList
'' ini$ = MakePath(DEST$, "DEMO.INI")
'' CreateIniKeyValue "WIN.INI", "MSSetup Sample 1", "Option", OPTCUR$, cmoNone
'' CreateIniKeyValue ini$, "Section 1", "Key 1", "Value 1" , cmoNone
'' CreateIniKeyValue ini$, "Section 2", "Key 2", "Value 2" , cmoNone
'' CreateIniKeyValue ini$, "Section 3", "Key 3", "Value 3" , cmoNone
CreateProgmanGroup "Interactive Physics 2.5", "", cmoNone
ShowProgmanGroup "Interactive Physics 2.5", 1, cmoNone
CreateProgmanItem "Interactive Physics 2.5", "Interactive Physics 2.5", MakePath(DEST$,"ip.exe"), "", cmoOverwrite
CreateProgmanItem "Interactive Physics 2.5", "Read Me", MakePath(DEST$,"readme.wri"), "", cmoOverwrite
CreateProgmanItem "Interactive Physics 2.5", "Release Notes", MakePath(DEST$,"relnotes.wri"), "", cmoOverwrite
CreateRegKeyValue ".ip", "IPII"
CreateRegKeyValue "IPII", "Interactive Physics 2.5 Document"
CreateRegKeyValue "IPII\shell\open\command", MakePath(DEST$,"ip.exe")+ " %1"
AddDos5Help "YOURAPP", "A brief help text for your Windows application."+chr$(10)+"It can be continued on another line with chr$(10).", cmoNone
CloseLogFile
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
'**
'** Purpose:
'** Adds the specified option files to the copy list.
'** Arguments:
'** ftype% - type of files to add, one of the following:
'** APPFILES, DEMOFILES, INTERACTIONFILES
'** Returns:
'** none.
'*************************************************************************
SUB AddOptFilesToCopyList (ftype%) STATIC
IF GetListItem(CHECKSTATES$, ftype%) = "ON" THEN
SrcDir$ = GetSymbolValue("STF_SRCDIR")
IF ftype% = APPFILES THEN
AddSectionFilesToCopyList "AppFiles", SrcDir$, DEST$
ELSEIF ftype% = DEMOFILES THEN
AddSectionFilesToCopyList "DemoFiles", SrcDir$, DEST$
ELSEIF ftype% = INTERACTIONFILES THEN
AddSectionFilesToCopyList "InteractionFiles", SrcDir$, DEST$
END IF
SrcDir$ = ""
END IF
END SUB
'**
'** Purpose:
'** Recalculates disk space for the given option files and sets
'** the status info symbol "StatusItemsText".
'** Arguments:
'** ftype% - type of files to add, one of the following:
'** APPFILES, DEMOFILES, INTERACTIONFILES
'** Returns:
'** none.
'*************************************************************************
SUB RecalcOptFiles (ftype%) STATIC
CursorSave% = ShowWaitCursor()
ClearCopyList
AddOptFilesToCopyList ftype%
fExtra% = 0
IF ftype% = APPFILES THEN
ListSym$ = APPNEEDS$
IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
''Add extra cost to Windows drive for ini/progman, etc.
ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
ReplaceListItem EXTRACOSTS$, ndrive%, "10240"
fExtra% = 1
END IF
ELSEIF ftype% = DEMOFILES THEN
ListSym$ = OPT1NEEDS$
ELSEIF ftype% = INTERACTIONFILES THEN
ListSym$ = OPT2NEEDS$
END IF
StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "")
cost& = 0
FOR i% = 1 TO 26 STEP 1
cost& = cost& + VAL(GetListItem(ListSym$, i%))
NEXT i%
ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024) + " K"
IF StillNeed& > 0 THEN
ReplaceListItem BIGLIST$, ftype%, "YES"
ELSE
ReplaceListItem BIGLIST$, ftype%, ""
END IF
IF fExtra% THEN
ReplaceListItem EXTRACOSTS$, ndrive%, "0"
END IF
RestoreCursor CursorSave%
ListSym$ = ""
END SUB
'**
'** Purpose:
'** Recalculates disk space and sets option status info according
'** to the current destination path.
'** Arguments:
'** none.
'** Returns:
'** none.
'*************************************************************************
SUB RecalcPath STATIC
CursorSave% = ShowWaitCursor()
RecalcOptFiles APPFILES
RecalcOptFiles DEMOFILES
RecalcOptFiles INTERACTIONFILES
RestoreCursor CursorSave%
END SUB
'**
'** Purpose:
'** Sets drive status info according to latest disk space calcs.
'** Arguments:
'** none.
'** Returns:
'** none.
'*************************************************************************
SUB SetDriveStatus STATIC
drive$ = MID$(DEST$, 1, 1)
ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1
cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(OPT1NEEDS$, ndrive%)) + VAL(GetListItem(OPT2NEEDS$, ndrive%))
free& = GetFreeSpaceForDrive(drive$)
ReplaceListItem DRIVETEXT$, 1, drive$ + ":"
ReplaceListItem DRIVETEXT$, 2, STR$(cost& / 1024) + " K"
ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " K"
IF drive$ = WINDRIVE$ THEN
ReplaceListItem DRIVETEXT$, 4, ""
ReplaceListItem DRIVETEXT$, 5, ""
ReplaceListItem DRIVETEXT$, 6, ""
ELSE
ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(OPT1NEEDS$, ndrive%)) + VAL(GetListItem(OPT2NEEDS$, ndrive%))
IF cost& = 0 THEN
ReplaceListItem DRIVETEXT$, 4, ""
ReplaceListItem DRIVETEXT$, 5, ""
ReplaceListItem DRIVETEXT$, 6, ""
ELSE
free& = GetFreeSpaceForDrive(WINDRIVE$)
ReplaceListItem DRIVETEXT$, 4, WINDRIVE$ + ":"
ReplaceListItem DRIVETEXT$, 5, STR$(cost& / 1024) + " K"
ReplaceListItem DRIVETEXT$, 6, STR$(free& / 1024) + " K"
END IF
END IF
END SUB