home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of Select: Games Special 3
/
cd.iso
/
wingames
/
powhouse
/
power.mst
< prev
next >
Wrap
Text File
|
1995-08-30
|
12KB
|
444 lines
'* POWER.MST - PowerHouse Setup Script
'**************************************************************************
'' Global variables
GLOBAL TitleShortName$
GLOBAL TitleLongName$
GLOBAL FileName$
GLOBAL PromptForPath%
GLOBAL DefaultPath$
GLOBAL ProgManGroup$
GLOBAL ProgManItem$
GLOBAL szTitleDir$
'' WinG globals
GLOBAL DEST$ ''Default destination directory.
GLOBAL bInstallDVA%
'' ****************************************************************
'' ** Setup Variables
'' ****************************************************************
'' Set the following string to a short form of the title name
TitleShortName$ = "PowerHouse"
'' Set the following string to a long form of the title name
TitleLongName$ = "PowerHouse"
'' Set the following variable to the name of the MVB file, without
FileName$ = "POWER"
'' prompt for path BOOL
PromptForPath% = 1
'' install path when prompt is displayed
DefaultPath$ = "C:\POWER"
'' program manager group
ProgManGroup$ = "PowerHouse"
'' program manager item title
ProgManItem$ = "PowerHouse"
'***********************************************************************
'** Mainline
'***********************************************************************
GLOBAL CUIDLL$
'' Include files
'$INCLUDE 'setupapi.inc'
'' Custom UI dll
CUIDLL$ = "mscuistf.dll"
'' Dialog ID's
CONST DESTPATH = 1000
CONST APPHELP = 2000
CONST TOOBIG = 3000
CONST BADPATH = 4000
CONST SUCCESS = 5000
CONST CONT_PH_SETUP = 101
CONST EXIT_PH_SETUP = 102
'' WinG DLG ID's
CONST CHECK = 2500
CONST EXITSUCCESS = 700
CONST EXITFAILURE = 400
CONST EXITQUIT = 600
'' Bitmap ID
CONST LOGO = 100
'' Functions and subroutines
DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
DECLARE FUNCTION GetTitleDir (szDefault$) AS STRING
DECLARE FUNCTION CopyFilesDisk1(szTitleDir$) AS INTEGER
DECLARE FUNCTION CopyFilesDisk2(szTitleDir$) AS INTEGER
DECLARE SUB ModifyProgramManager
DECLARE SUB ShowSuccess
'' functions from WinG install
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$)
'' first we make a backup of the windows\system\dva.386 file
'' copy is called dva386.imp
'' problems occured with this file with certain versions of windows
'' had problems running this .exe file
szInf$ = GetSymbolValue("STF_SRCDIR")
''RUN szInf$+"saveme.exe "
'' this section does exactly what the much larger preceding
'' program does but in only 2 lines
''sz$ = GetWindowsSysDir
''i% = FCopyOneFile (sz$+"dva.386",sz$+"dva386.imp",cmoCopy,0)
'' return value displayer
''i% = DoMsgBox(STR$(i%), "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
INIT:
bInstallDVA% = 0
CUIDLL$ = "mscuistf.dll" ''Custom user interface dll
HELPPROC$ = "FHelpDlgProc" ''Help dialog procedure
'' Set the title and banner bitmap. You must rebuild MSCUISTF.DLL to
'' alter the banner bitmap.
SetTitle "PowerHouse"
SetBitmap CUIDLL$, LOGO
'' sz$ = UIStartDlg(CUIDLL$, CONT_PH_SETUP, "FInfoDlgProc", APPHELP, HELPPROC$)
'' IF sz$ <> "CONTINUE" THEN
'' ERROR EXIT_PH_SETUP
'' GOTO QUIT
'' END IF
'' UIPop 1
szInf$ = GetSymbolValue("STF_SRCINFPATH")
IF szInf$ = "" THEN
szInf$ = GetSymbolValue("STF_CWDDIR") + "wing.inf"
END IF
ReadInfFile szInf$
CHECK:
SrcDir$ = GetSymbolValue("STF_SRCDIR")
SrcDrive$ = MID$(SrcDir$,1,1)
SrcDir$ = SrcDrive$+":\SYSTEM\"
''i% = DoMsgBox(SrcDrive$, "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
DEST$ = GetWindowsSysDir
AddSectionFilesToCopyList "runtime", SrcDir$, DEST$
'
' only use DVA on Windows 3.x
'
IF OnWin3x() = 1 THEN
AddSectionFilesToCopyList "dva", SrcDir$, DEST$
IF VflatdPresent() = 0 THEN
CreateSysIniKeyValue GetWindowsDir + "system.ini", "386Enh", "device", GetWindowsSysDir+"dva.386", cmoOverwrite
bInstallDVA% = 1
END IF
END IF
DEST$ = GetRealWindowsSysDir
AddSectionFilesToCopyList "wing32", SrcDir$, DEST$
Dest1$ = MakePath(DEST$,"wing32.dll")
Dest2$ = MakePath(DEST$,"wing32.xxx")
RenameFilePlease Dest1$,Dest2$
CopyFilesInCopyList
UpdateWinG32 GetRealWindowsSysDir()
POWER:
'' now install powerhouse files
'' The following statement turns size checking off. Set it to scmOnFatal
'' to enable size checking, where Setup will compare the disk file size
'' with the INF file size and report an error if they are not the same.
i% = SetSizeCheckMode(scmOff)
'' Read in the INF file.
ReadInfFile GetSymbolValue("STF_CWDDIR") + "POWER.INF"
'' Decide where to put title files
IF PromptForPath% = 1 THEN
szTitleDir$ = GetTitleDir(DefaultPath$)
IF szTitleDir$ = "" THEN
ERROR STFQUIT
GOTO QUIT
ENDIF
ELSE
''szTitleDir$ = GetWindowsDir()
szTitleDir$ = "C:\POWER"
ENDIF
'' Copy files
IF CopyFilesDisk1(szTitleDir$) = 0 THEN
GOTO QUIT
ENDIF
ModifyProgramManager
ShowSuccess
END
QUIT:
ON ERROR GOTO ERRQUIT
IF ERR = 0 THEN
dlg% = EXITSUCCESS
ELSEIF ERR = STFQUIT THEN
dlg% = EXITQUIT
ELSEIF ERR = EXIT_PH_SETUP THEN
dlg% = EXIT_PH_SETUP
ELSE
dlg% = EXITFAILURE
END IF
'' i% = DoMsgBox(STR$(ERR)+" "+STR$(dlg%), "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
UIPop 1
sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfoDlgProc", 0, "")
END
ERRQUIT:
i% = DoMsgBox("Setup sources were corrupted, call 555-1212!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
END
'*************************************************************************
'** Purpose:
'** Prompts the user for a path for the title files
'** Arguments:
'** szDefault$ - default path
'** Returns:
'** New valid path name, or "" if the user quit.
'*************************************************************************
FUNCTION GetTitleDir (szDefault$) STATIC AS STRING
SetSymbolValue "String", TitleShortName$
SetSymbolValue "EditTextIn", szDefault$
SetSymbolValue "EditFocus", "ALL"
GETPATH:
sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, "FHelpDlgProc")
IF sz$ = "CONTINUE" THEN
szTitleDir$ = GetSymbolValue("EditTextOut")
IF IsDirWritable(szTitleDir$) = 0 THEN
BADPATH:
sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfoDlgProc", 0, "")
IF sz$ = "REACTIVATE" THEN
GOTO BADPATH
END IF
UIPop 1
GOTO GETPATH
END IF
UIPop 1
CreateDir szTitleDir$, cmoNone
ELSEIF sz$ = "REACTIVATE" THEN
GOTO GETPATH
ELSE
szTitleDir$ = ""
END IF
GetTitleDir = szTitleDir$
END FUNCTION
'*************************************************************************
'** Purpose:
'** Copies the files in the INF file
'** Arguments:
'** szTitleDir$ - destination directory for the title files
'** Returns
'** 1 if files were copied, 0 otherwise
'*************************************************************************
FUNCTION CopyFilesDisk1(szTitleDir$) STATIC AS INTEGER
'' Add all system files to the copy list
AddSectionFilesToCopyList "System Files", GetSymbolValue("STF_SRCDIR"), GetWindowsSysDir()
'' Add all of the title files to the copy list
AddSectionFilesToCopyList "Installed Title Files", GetSymbolValue("STF_SRCDIR"), szTitleDir$
'' Check size
szExtras$ = "Extra"
szCosts$ = "Costs"
szNeededs$ = "Neededs"
FOR i% = 1 TO 26 STEP 1
AddListItem szExtras$, "0"
NEXT i%
'' We assume that VIEWER.INI will take another 4K
ReplaceListItem szExtras$, ASC(MID$(UCASE$(GetWindowsDir()), 1, 1)) - ASC("A") + 1, STR$(4096)
'' Get amount of space required
StillNeed& = GetCopyListCost(szExtras$, szCosts$, szNeededs$)
'' Put up a message if there is not enough space
FOR i% = 1 TO 26 STEP 1
IF VAL(GetListItem(szNeededs$, i%)) > 0 THEN
SetSymbolValue "String1", LTRIM$(STR$(VAL(GetListItem(szCosts$, i%)) / 1024))
SetSymbolValue "String2", CHR$(i% - 1 + ASC("A"))
TOOBIG:
sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfoDlgProc", 0, "")
IF sz$ = "REACTIVATE" THEN
GOTO TOOBIG
END IF
UIPop 1
CopyFilesDisk1 = 0
GOTO DONTCOPY
END IF
NEXT i%
'' Copy the files
CopyFilesInCopyList
CopyFilesDisk1 = 1
DONTCOPY:
END FUNCTION
'*************************************************************************
'** Purpose:
'** Puts up a success dialog
'*************************************************************************
SUB ShowSuccess STATIC
SUCCESS:
SetSymbolValue "String1", TitleShortName$
sz$ = UIStartDlg(CUIDLL$, SUCCESS, "FInfoDlgProc", 0, "")
IF sz$ = "REACTIVATE" THEN
GOTO SUCCESS
END IF
UIPop 1
END SUB
'*************************************************************************
'** Purpose:
'** Creates program manager entries for the title
'*************************************************************************
SUB ModifyProgramManager STATIC
'' Create the program manager group
CreateProgmanGroup ProgmanGroup$, "", cmoNone
ShowProgmanGroup ProgmanGroup$, 1, cmoNone
CreateProgmanItem ProgmanGroup$, ProgmanItem$, szTitleDir$+"\POWHSDEM.EXE",szTitleDir$+"\POWERH.ICO",cmoOverwrite
''SrcDir$ = GetSymbolValue("STF_SRCDIR")
''SrcDrive$ = MID$(SrcDir$,1,1)
''CreateProgmanItem ProgmanGroup$, "On-Line", SrcDrive$+":\POWERON\GERMAN.WRI",SrcDrive$+":\POWERON\POWERON.ICO",cmoOverwrite
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