home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD-ROM Magazin 1996 March (Planer)
/
PLANER.BIN
/
sharewar
/
win3.x
/
gore2
/
dasetup.ms_
/
dasetup.bin
Wrap
Text File
|
1995-08-07
|
18KB
|
604 lines
'**************************************************************************
'* Setup
'**************************************************************************
''$DEFINE DEBUG ''Define for script development/debugging
'$DEFINE BSNORM ''Define for normal BS
''$DEFINE CUSTOM ''Define for special boxes
'$INCLUDE 'setupapi.inc'
'$INCLUDE 'msdetect.inc'
''$INCLUDE 'msregdb.inc'
rem /-------------------------------------------------------------------\
rem
rem constants definition
rem
rem \-------------------------------------------------------------------/
''Dialog ID's
''=======================
CONST WELCOME = 101
CONST ASKQUIT = 200
CONST DESTPATH = 300
CONST EXITFAILURE = 400
CONST EXITQUIT = 600
CONST EXITSUCCESS = 700
CONST OPTIONS = 800
CONST APPHELP = 900
CONST TOOBIG = 6300
CONST BADPATH = 6400
CONST DACUST1 = 7801
CONST DACUST2 = 7901
CONST SETTIME = 7900
CONST DAREADME = 8000
''Bitmap ID
CONST LOGO = 1
''File Types
CONST OPTFILES1 = 1
CONST OPTFILES2 = 2
CONST APPFILES = 3
CONST WINFILES = 4
rem /-------------------------------------------------------------------\
rem
rem Var's
rem
rem \-------------------------------------------------------------------/
GLOBAL DEST$ ''Default destination directory.
GLOBAL OPTCUR$ ''Option selection from option dialog.
GLOBAL WINDRIVE$ ''Windows drive letter.
GLOBAL SHOW$ ''
GLOBAL OPT1OPT$ ''Option selection from OptFiles1 option dialog.
GLOBAL OPT2OPT$ ''Option selection from OptFiles2 option dialog.
''CustInst list symbol names
GLOBAL EXTRACOSTS$ ''List of extra costs to add per drive
GLOBAL BIGLIST$ ''List of option files cost calc results (boolean)
GLOBAL APPNEEDS$ ''Option list costs per drive for Apps
GLOBAL OPT1NEEDS$ ''Option list costs for Option1
GLOBAL OPT2NEEDS$ ''Option list costs for Option2
''Dialog list symbol names
GLOBAL CHECKSTATES$ '' Checked/Unchecked Options
GLOBAL STATUSTEXT$ ''
GLOBAL DRIVETEXT$ '' drive, cost, free + windrive, cost, free
rem /-------------------------------------------------------------------\
rem
rem function declaration
rem
rem \-------------------------------------------------------------------/
DECLARE SUB AddOptFilesToCopyList (ftype%)
DECLARE SUB RecalcOptFiles (ftype%)
DECLARE SUB RecalcPath
DECLARE SUB SetDriveStatus
DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
DECLARE FUNCTION ShowWindow LIB "user.exe" (hwnd% ,Mode%) AS INTEGER
DECLARE FUNCTION SystemParametersInfo LIB "user.exe" (Action% ,Param%, szDummy$ ,Ini%) AS INTEGER
DECLARE FUNCTION WinExec LIB "kernel.exe" (szFile$ ,Mode%) AS INTEGER
DECLARE SUB Install
rem /-------------------------------------------------------------------\
rem
rem initializing
rem
rem \-------------------------------------------------------------------/
INIT:
'' global symbols
CUIDLL$ = "mscuistf.dll" ''Custom user interface dll
HELPPROC$ = "FHelpDlgProc" ''Help dialog procedure
''Disk cost list symbols
APPNEEDS$ = "AppNeeds"
OPT1NEEDS$ = "Opt1Needs"
OPT2NEEDS$ = "Opt2Needs"
EXTRACOSTS$ = "ExtraCosts"
BIGLIST$ = "BigList"
ret%=ShowWindow(HwndFrame,3) ''show fullscreen-setup
SetBitmap CUIDLL$, LOGO
SetTitle "Installation Bildschirmschoner"
szInf$ = GetSymbolValue("STF_SRCINFPATH")
IF szInf$ = "" THEN
szInf$ = GetSymbolValue("STF_CWDDIR") + "dasetup.INF"
END IF
ReadInfFile szInf$
WINDRIVE$ = MID$(GetWindowsDir, 1, 1)
DEST$ = GetWindowsDir
'$IFDEF CUSTOM
''CustInst list symbols
CHECKSTATES$ = "CheckItemsState"
STATUSTEXT$ = "StatusItemsText"
DRIVETEXT$ = "DriveStatusText"
FOR i% = 1 TO 2 STEP 1 '' Optionen1 + 2 auf ON
AddListItem CHECKSTATES$, "ON"
NEXT i%
FOR i% = 1 TO 3 STEP 1
AddListItem STATUSTEXT$, "" '' Statustexte loeschen
NEXT i%
FOR i% = 1 TO 7 STEP 1
AddListItem DRIVETEXT$, ""
NEXT i%
ReplaceListItem DRIVETEXT$, 7, DEST$ '' Ziellaufwerk anzeigen
FOR i% = 1 TO 3 STEP 1
AddListItem BIGLIST$, ""
NEXT i%
'$ENDIF ''CUSTOM
FOR i% = 1 TO 26 STEP 1
AddListItem EXTRACOSTS$, "0"
NEXT i%
'$IFDEF CUSTOM
RecalcPath '' Paltzbedarf berechnen
SetDriveStatus '' und anzeigen
'$ENDIF
'$IFDEF DEBUG
i% = SetSizeCheckMode(scmOnIgnore) '' could use scmOff; def = scmOnFatal
'$ENDIF ''DEBUG
''===================================================
''
'' Dialog-Box anzeigen (Information)
''
''===================================================
WELCOME:
sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$)
IF sz$ = "CONTINUE" THEN
UIPop 1
ELSE
GOSUB ASKQUIT
GOTO WELCOME
END IF
''===================================================
''
'' Dialog-Box anzeigen (Optionen)
''
''===================================================
'$IFDEF CUSTOM
CUSTINST:
sz$ = UIStartDlg(CUIDLL$, DACUST2, "FCustInstDlgProc", APPHELP, HELPPROC$)
IF sz$ = "CONTINUE" THEN
''min 1 Option must be selected
IF GetListItem(CHECKSTATES$, OPTFILES1) = "OFF" AND GetListItem(CHECKSTATES$, OPTFILES2) = "OFF" THEN
i% = DoMsgBox("Mindestens eine Bibliothek mu▀ installiert werden!", "Setup", MB_OK+MB_TASKMODAL+MB_ICONHAND)
GOTO CUSTINST
END IF
''Install only if it will fit.
FOR i% = 1 TO 2 STEP 1
IF GetListItem(BIGLIST$, i%) <> "" THEN
GOSUB TOOBIG
GOTO CUSTINST
END IF
NEXT i%
UIPop 1
GOTO GOINSTALL
ELSEIF sz$ = "CHK1" THEN
RecalcOptFiles OPTFILES1
SetDriveStatus
GOTO CUSTINST
ELSEIF sz$ = "CHK2" THEN
RecalcOptFiles OPTFILES2
SetDriveStatus
GOTO CUSTINST
ELSEIF sz$ = "REACTIVATE" THEN
RecalcPath
SetDriveStatus
GOTO CUSTINST
ELSE
GOSUB ASKQUIT
GOTO CUSTINST
END IF
goto ENDCHECKSIZE '' Werte werden oben bereits einzeln angezeigt
'' Checksize im ganzen also nicht noetig
'$ENDIF
''===================================================
''
'' Benoetigt, wenn keine Optionsbox
''
''===================================================
'$IFDEF BSNORM
CHECKSIZE:
SrcDir$ = GetSymbolValue("STF_SRCDIR")
ClearCopyList
AddSectionFilesToCopyList "AppFiles", SrcDir$, DEST$
'' AddSectionFilesToCopyList "Opt1", SrcDir$, DEST$
'' AddSectionFilesToCopyList "Opt2", SrcDir$, DEST$
''Add extra cost to Windows drive for ini/progman, etc.
ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
ReplaceListItem EXTRACOSTS$, ndrive%, "10240"
StillNeed& = GetCopyListCost(EXTRACOSTS$, APPNEEDS$, "")
ReplaceListItem EXTRACOSTS$, ndrive%, "0"
if StillNeed& > 0 THEN
text$="Das Programm kann nicht installiert werden. Es fehlen "+ STR$(StillNeed&/1000) + " KB freier Speicherplatz auf dem Laufwerk auf dem Windows installiert wurde."
i% = DoMsgBox(text$, "Achtung", MB_OK+MB_TASKMODAL+MB_ICONHAND)
dlg% = EXITFAILURE
GOTO QUITL1
ELSE
GOTO GOINSTALL
END IF
ENDCHECKSIZE:
'$ENDIF
GOINSTALL:
Install '' Call Sub for copying
GOTO README
TIMEDLG:
CUIDLL$ = "mscuistf.dll" ''Custom user interface dll
HELPPROC$ = "FHelpDlgProc" ''Help dialog procedure
sz$ = UIStartDlg(CUIDLL$, SETTIME, "FSetTimeDlgProc", APPHELP, HELPPROC$)
IF sz$ = "CONTINUE" THEN
UIPop 1
ELSEIF sz$ = "CANCEL" THEN
UIPop 1
ELSE
GOTO TIMEDLG
END IF
README:
READMEF$=GetSectionKeyFileName("AppFiles","TXT")
READMEP$=MakePath (GetWindowsDir , READMEF$)
SetSymbolValue "ConfirmtextIn", ""
AddListItem "ConfirmTextIn", "Weitere Informationen k÷nnen Sie in der Datei " + READMEF$ + " im Windows-Verzeichnis nachlesen."
sz$ = UIStartDlg(CUIDLL$, DAREADME, "FConfirmDlgProc", APPHELP, HELPPROC$)
IF sz$ = "CONTINUE" THEN
UIPop 1
ret%=WinExec("notepad.exe " + READMEP$,5)
GOTO QUITL2
ELSE
UIPop 1
GOTO QUITL2
END IF
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
QUITL2:
'$IFDEF DEBUG
CloseLogFile
'$ENDIF ''DEBUG
END
ERRQUIT:
i% = DoMsgBox("Setup sources were corrupted!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
END
rem /-------------------------------------------------------------------\
rem | |
rem | subfunctions / procedures |
rem | |
rem \-------------------------------------------------------------------/
'========================================================================
'
' Install
'
'=========================================================================
'**
'** Purpose:
'** Builds the copy list and performs all installation operations.
'** Arguments:
'** none.
'** Returns:
'** none.
'*************************************************************************
SUB Install STATIC
'' JHC
'$IFDEF DEBUG
OpenLogFile MakePath(DEST$, "LOGFILE.OUT"), 0
WriteToLogFile "starting with Install"
WriteToLogFile ""
WriteToLogFile " User chose as destination directory: '" + DEST$ + "'"
WriteToLogFile " User chose option: '" + GetListItem(CHECKSTATES$, OPTFILES1) + "'"
WriteToLogFile " User chose option: '" + GetListItem(CHECKSTATES$, OPTFILES2) + "'"
WriteToLogFile ""
WriteToLogFile "May have had to create the directory: " + DEST$
WriteToLogFile ""
'$ENDIF ''DEBUG
SrcDir$ = GetSymbolValue("STF_SRCDIR")
ClearCopyList
AddOptFilesToCopyList WINFILES
AddOptFilesToCopyList APPFILES
'' AddOptFilesToCopyList OPTFILES1
'' AddOptFilesToCopyList OPTFILES2
ret%=SystemParametersInfo (17 ,0 , "" ,3 ) '' write and change
CopyFilesInCopyList
SYSINI$ = GetWindowsDir+"system.ini"
WININI$ = GetWindowsDir+"win.ini"
CONINI$ = GetWindowsDir+"control.ini"
SPATH$ = GetWindowsDir + GetSectionKeyFileName("WinFiles","SCR")
CreateIniKeyValue SYSINI$, "Boot", "SCRNSAVE.EXE", SPATH$, cmoOverwrite
'' BS Aktiv schalten
ret%=SystemParametersInfo (17 ,1 , "" ,1 ) '' update ini-file
ret%=SystemParametersInfo (15 ,120 , "" ,3 ) '' write and send message
END SUB
'========================================================================
'
' AddOptFilesToCopyList
'
'=========================================================================
'**
'** Purpose:
'** Adds the specified option files to the copy list.
'** Arguments:
'** ftype% - type of files to add, one of the following:
'** APPFILES, OPTFILES1, OPTFILES2
'** Returns:
'** none.
'-------------------------------------------------------------------------
SUB AddOptFilesToCopyList (ftype%) STATIC
SrcDir$ = GetSymbolValue("STF_SRCDIR")
IF ftype% = OPTFILES1 THEN
IF GetListItem(CHECKSTATES$, ftype%) = "ON" THEN
AddSectionFilesToCopyList "Option1", SrcDir$, Dest$
END IF
ELSEIF ftype% = OPTFILES2 THEN
IF GetListItem(CHECKSTATES$, ftype%) = "ON" THEN
AddSectionFilesToCopyList "Option2", SrcDir$, Dest$
END IF
ELSEIF ftype% = WINFILES THEN
AddSectionFilesToCopyList "WinFiles", SrcDir$, GetWindowsDir
ELSEIF ftype% = APPFILES THEN
AddSectionFilesToCopyList "AppFiles", SrcDir$, Dest$
END IF
SrcDir$ = ""
END SUB
'========================================================================
'
' RecalcOptFiles
'
'=========================================================================
'**
'** 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, OPTFILES1, OPTFILES2
'** Returns:
'** none.
'-------------------------------------------------------------------------
SUB RecalcOptFiles (ftype%) STATIC
CursorSave% = ShowWaitCursor()
ClearCopyList
AddOptFilesToCopyList ftype%
fExtra% = 0
IF ftype% = APPFILES THEN
AddOptFilesToCopyList WINFILES
ListSym$ = APPNEEDS$
''Add extra cost to Windows drive for ini/progman, etc.
ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
ReplaceListItem EXTRACOSTS$, ndrive%, "10240"
fExtra% = 1
ELSEIF ftype% = OPTFILES1 THEN
ListSym$ = OPT1NEEDS$
ELSEIF ftype% = OPTFILES2 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
'========================================================================
'
' RecalcPath (all Options)
'
'=========================================================================
'**
'** 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 OPTFILES1
RecalcOptFiles OPTFILES2
RestoreCursor CursorSave%
END SUB
'========================================================================
'
' SetDriveStatus (Show results)
'
'=========================================================================
'**
'** 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
'========================================================================
'
' MakePath
'
'=========================================================================
'**
'** 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
''========================================================
''
'' show messagebox if not enough available disk-space
''
''========================================================
TOOBIG:
sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
IF sz$ = "REACTIVATE" THEN
RecalcPath
SetDriveStatus
GOTO TOOBIG
END IF
UIPop 1
RETURN
''========================================================
''
'' show messagebox if Path not exists
''
''========================================================
BADPATH:
sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
IF sz$ = "REACTIVATE" THEN
GOTO BADPATH
END IF
UIPop 1
RETURN
''========================================================
''
'' show messagebox , ask for quitting setup
''
''========================================================
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