home *** CD-ROM | disk | FTP | other *** search
Wrap
'$DEFINE DEBUG ''Define for script development/debugging '$INCLUDE 'setupapi.inc' '$INCLUDE 'msdetect.inc' ''Dialog ID's CONST ASKQUIT = 200 CONST DESTPATH = 300 CONST EXITFAILURE = 400 CONST EXITQUIT = 600 CONST EXITSUCCESS = 700 CONST APPHELP = 900 CONST CUSTINST = 6200 CONST TOOBIG = 6300 CONST BADPATH = 6400 CONST PASSWORDID = 4571 CONST NODLGEXIT = 800 ''Bitmap ID CONST LOGO = 1 ''File Types CONST APPFILES = 1 CONST ARCHIVFILES = 2 CONST SAMPLEFILES = 3 GLOBAL DEST$ ''Default destination directory. GLOBAL USERNAME$ GLOBAL USERORG$ GLOBAL SAMPLEDIR$ ''Adresar SAMPLE GLOBAL WINDRIVE$ ''Windows drive letter. GLOBAL WINSYSDIR$ GLOBAL IconStr$ GLOBAL TESTD ''CustInst list symbol names GLOBAL APPNEEDS$ ''Option list costs per drive GLOBAL SAMPLENEEDS$ GLOBAL ARCHIVNEEDS$ 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 AddOptFilesToCopyList (ftype%) DECLARE SUB AddZBLZVLFilesToCopyList DECLARE SUB RecalcOptFiles (ftype%) DECLARE SUB RecalcPath DECLARE SUB SetDriveStatus DECLARE SUB WriteSetupKeyIntoApp LIB "ctxstpui.dll" (lpTargetDir$,lpUserName$,lpUserOrg$) DECLARE FUNCTION TestDemo LIB "ctxstpui.dll" (lpTargetDir$) AS INTEGER DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING INIT: CUIDLL$ = "ctxstpui.dll" ''custom user interface dll HELPPROC$ = "UIHelpDialog" ''Help dialog procedure SetBitmap CUIDLL$, LOGO SetTitle "Zoner Context 2.0 - zkuÜebnφ verze" szInf$ = GetSymbolValue("STF_SRCINFPATH") IF szInf$ = "" THEN szInf$ = GetSymbolValue("STF_CWDDIR") + "CONTEXT.INF" END IF ReadInfFile szInf$ WINDRIVE$ = MID$(GetWindowsDir, 1, 1) DEST$ = WINDRIVE$ + ":\CONTEXT" WINSYSDIR$ = GetWindowsSysDir GOSUB GENSUBDIRS ''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" SAMPLENEEDS$ = "SampleNeeds" 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% RecalcPath SetDriveStatus '$IFDEF DEBUG i% = SetSizeCheckMode(scmOnIgnore) '' could use scmOff; def = scmOnFatal '$ENDIF ''DEBUG TESTD = TestDemo(DEST$) IF TESTD = 0 THEN UIPopAll ERROR NODLGEXIT RETURN ENDIF CUSTINST: sz$ = UIStartDlg(CUIDLL$, CUSTINST, "ContextSetupDlg", APPHELP, HELPPROC$) IF sz$ = "CONTINUE" THEN ''Install only if it will fit. FOR i% = 1 TO 3 STEP 1 IF GetListItem(BIGLIST$, i%) <> "" THEN GOSUB TOOBIG GOTO CUSTINST END IF NEXT i% UIPop 1 GOTO INSTALL ELSEIF sz$ = "PATH" THEN GOTO GETPATH ELSEIF sz$ = "CHK1" THEN RecalcPath SetDriveStatus GOTO CUSTINST ELSEIF sz$ = "CHK2" THEN RecalcPath SetDriveStatus GOTO CUSTINST ELSEIF sz$ = "CHK3" THEN RecalcPath SetDriveStatus GOTO CUSTINST ELSEIF sz$ = "REACTIVATE" THEN RecalcPath SetDriveStatus GOTO CUSTINST ELSE GOSUB ASKQUIT GOTO CUSTINST END IF INSTALL: SetSymbolValue "UserNameTextIn", USERNAME$ SetSymbolValue "UserOrgTextIn", USERORG$ SetSymbolValue "PasswordFocus", "END" GETPASSWORDL1: sz$ = UIStartDlg(CUIDLL$, PASSWORDID, "FPasswordDlgProc", APPHELP, HELPPROC$) IF sz$ = "CONTINUE" THEN USERNAME$ = GetSymbolValue("UserNameTextOut") USERORG$ = GetSymbolValue("UserOrgTextOut") UIPop 1 GOTO FINALINSTALL ELSEIF sz$ = "REACTIVATE" THEN GOTO GETPASSWORDL1 ELSEIF sz$ = "EXIT" THEN GOSUB ASKQUIT GOTO GETPASSWORDL1 ELSE UIPop 1 GOTO GETPASSWORDL1 END IF FINALINSTALL: ClearCopyList AddOptFilesToCopyList APPFILES AddOptFilesToCopyList SAMPLEFILES AddZBLZVLFilesToCopyList SetRestartDir DEST$ IF (GetListItem(CHECKSTATES$, APPFILES) = "ON") THEN CreateDir DEST$, cmoNone END IF IF GetListItem(CHECKSTATES$, SAMPLEFILES) = "ON" THEN CreateDir SAMPLEDIR$, cmoNone END IF CopyFilesInCopyList IF (GetListItem(CHECKSTATES$, APPFILES) = "ON") OR (GetListItem(CHECKSTATES$, ARCHIVFILES) = "ON") THEN CreateProgmanGroup "Zoner Context verze 2.0", "", cmoNone ShowProgmanGroup "Zoner Context verze 2.0", 1, cmoNone END IF IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN CreateProgmanItem "Zoner Context verze 2.0", "Zoner Context", MakePath(DEST$,"context.exe"), "", cmoOverwrite CreateProgmanItem "Zoner Context verze 2.0", "Zoner Context Editor", MakePath(DEST$,"contedit.exe"), "", cmoOverwrite CreateProgmanItem "Zoner Context verze 2.0", "Zoner Context Compiler", MakePath(DEST$,"ctxcomp.exe"), "", cmoOverwrite END IF IF GetListItem(CHECKSTATES$, SAMPLEFILES) = "ON" THEN IconStr$=MakePath(DEST$,"context.exe")+",1" CreateProgmanItem "Zoner Context verze 2.0", "Dinosau°i", MakePath(DEST$,"context.exe") + " " + MakePath(SAMPLEDIR$,"dinos.ctx"), IconStr$, cmoOverwrite END IF WriteSetupKeyIntoApp DEST$,USERNAME$,USERORG$ QUIT: ON ERROR GOTO ERRQUIT IF ERR = NODLGEXIT THEN GOTO NODLGQUIT ENDIF IF ERR = 0 THEN dlg% = EXITSUCCESS ELSEIF ERR = STFQUIT THEN dlg% = EXITQUIT ELSEIF ERR = NODLGEXIT THEN dlg% = 0 ELSE dlg% = EXITFAILURE END IF QUITL1: sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "") IF sz$ = "REACTIVATE" THEN GOTO QUITL1 END IF UIPop 1 IF dlg%=EXITSUCCESS THEN IF RestartListEmpty() = 0 THEN i% = DoMsgBox("Instalßtor musφ nynφ restartovat Windows. Uzav°ete prosφm vÜechny ostatnφ aplikace a stiskn∞te tlaΦφtko OK.", "Zprßva instalßtoru", MB_OK+MB_ICONINFORMATION) AGAINEX: IF ExitExecRestart()=0 THEN i% = DoMsgBox("Restartovßnφ Windows selhalo. Uzav°ete vÜechny aplikace pro MS-DOS a stiskn∞te tlaΦφtko OK.", "Zprßva instalßtoru", MB_OK+MB_ICONINFORMATION) GOTO AGAINEX END IF END IF END IF END ERRQUIT: i% = DoMsgBox("ZdrojovΘ soubory Setupu jsou poÜkozeny!", "Zprßva instalßtoru", MB_OK+MB_TASKMODAL+MB_ICONHAND) END NODLGQUIT: END GETPATH: SetSymbolValue "EditTextIn", DEST$ SetSymbolValue "EditFocus", "END" GETPATHL1: sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$) IF sz$ = "CONTINUE" THEN olddest$ = DEST$ DEST$ = GetSymbolValue("EditTextOut") ''Validate new path. IF IsDirWritable(DEST$) = 0 THEN GOSUB BADPATH GOTO GETPATHL1 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 GOSUB GENSUBDIRS RecalcPath SetDriveStatus END IF olddest$ = "" GOTO CUSTINST ELSEIF sz$ = "REACTIVATE" THEN GOSUB GENSUBDIRS RecalcPath SetDriveStatus GOTO GETPATHL1 ELSEIF sz$ = "EXIT" THEN GOSUB ASKQUIT GOTO GETPATHL1 ELSE UIPop 1 GOTO CUSTINST END IF TOOBIG: sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "") IF sz$ = "REACTIVATE" THEN RecalcPath SetDriveStatus GOTO TOOBIG END IF UIPop 1 RETURN GENSUBDIRS: IF MID$(DEST$,LEN(DEST$),1) = "\" THEN SAMPLEDIR$ = DEST$ + "SAMPLES" ELSE SAMPLEDIR$ = DEST$ + "\SAMPLES" END IF RETURN BADPATH: sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "") IF sz$ = "REACTIVATE" THEN RecalcPath SetDriveStatus 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 '** '** Purpose: '** Adds the specified option files to the copy list. '** Arguments: '** ftype% - type of files to add, one of the following: '** APPFILES, SAMPLEFILES '** Returns: '** none. '************************************************************************* SUB AddOptFilesToCopyList (ftype%) STATIC IF GetListItem(CHECKSTATES$, ftype%) = "ON" THEN SrcDir$ = GetSymbolValue("STF_SRCDIR") IF ftype% = APPFILES THEN AddSectionFilesToCopyList "App", SrcDir$, DEST$ AddSectionFilesToCopyList "AppWinSys", SrcDir$, WINSYSDIR$ ELSEIF ftype% = SAMPLEFILES THEN AddSectionFilesToCopyList "Sample", SrcDir$, SAMPLEDIR$ END IF SrcDir$ = "" END IF END SUB SUB AddZBLZVLFilesToCopyList STATIC IF (GetListItem(CHECKSTATES$, APPFILES) = "ON") THEN SrcDir$ = GetSymbolValue("STF_SRCDIR") AddSectionFilesToCopyList "ZBLZVL", SrcDir$, DEST$ 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, SAMPLEFILES '** Returns: '** none. '************************************************************************* SUB RecalcOptFiles (ftype%) STATIC CursorSave% = ShowWaitCursor() ClearCopyList AddOptFilesToCopyList ftype% fExtra% = 0 IF ftype% = APPFILES THEN ListSym$ = APPNEEDS$ ELSEIF ftype% = SAMPLEFILES THEN ListSym$ = SAMPLENEEDS$ ENDIF 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 SAMPLEFILES 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(SAMPLENEEDS$, 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(SAMPLENEEDS$, 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 '** '** 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