Annotation of mstools/mssetup/sample2.mst, revision 1.1

1.1     ! root        1: '**************************************************************************
        !             2: '*                       MSSetup Toolkit Sample 2
        !             3: '**************************************************************************
        !             4: 
        !             5: '$DEFINE DEBUG  ''Define for script development/debugging
        !             6: 
        !             7: '$INCLUDE 'setupapi.inc'
        !             8: '$INCLUDE 'msdetect.inc'
        !             9: 
        !            10: ''Dialog ID's
        !            11: CONST ASKQUIT      = 200
        !            12: CONST DESTPATH     = 300
        !            13: CONST EXITFAILURE  = 400
        !            14: CONST EXITQUIT     = 600
        !            15: CONST EXITSUCCESS  = 700
        !            16: CONST OPTIONS      = 800
        !            17: CONST APPHELP      = 900
        !            18: CONST CUSTINST     = 6200
        !            19: CONST TOOBIG       = 6300
        !            20: CONST BADPATH      = 6400
        !            21: 
        !            22: ''Bitmap ID
        !            23: CONST LOGO         = 1
        !            24: 
        !            25: ''File Types
        !            26: CONST APPFILES     = 1
        !            27: CONST OPTFILES1    = 2
        !            28: CONST OPTFILES2    = 3
        !            29: 
        !            30: 
        !            31: GLOBAL DEST$        ''Default destination directory.
        !            32: GLOBAL WINDRIVE$    ''Windows drive letter.
        !            33: GLOBAL OPT1OPT$     ''Option selection from OptFiles1 option dialog.
        !            34: GLOBAL OPT2OPT$     ''Option selection from OptFiles2 option dialog.
        !            35: 
        !            36: ''CustInst list symbol names
        !            37: GLOBAL APPNEEDS$    ''Option list costs per drive
        !            38: GLOBAL OPT1NEEDS$
        !            39: GLOBAL OPT2NEEDS$
        !            40: GLOBAL EXTRACOSTS$  ''List of extra costs to add per drive
        !            41: GLOBAL BIGLIST$     ''List of option files cost calc results (boolean)
        !            42: 
        !            43: ''Dialog list symbol names
        !            44: GLOBAL CHECKSTATES$
        !            45: GLOBAL STATUSTEXT$
        !            46: GLOBAL DRIVETEXT$
        !            47: 
        !            48: 
        !            49: DECLARE SUB AddOptFilesToCopyList (ftype%)
        !            50: DECLARE SUB RecalcOptFiles (ftype%)
        !            51: DECLARE SUB RecalcPath
        !            52: DECLARE SUB SetDriveStatus
        !            53: DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
        !            54: 
        !            55: 
        !            56: 
        !            57: INIT:
        !            58:     CUIDLL$ = "mscuistf.dll"            ''custom user interface dll
        !            59:     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
        !            60: 
        !            61:     SetBitmap CUIDLL$, LOGO
        !            62:     SetTitle "MSSetup Toolkit Sample 2"
        !            63: 
        !            64:     szInf$ = GetSymbolValue("STF_SRCINFPATH")
        !            65:     IF szInf$ = "" THEN
        !            66:         szInf$ = GetSymbolValue("STF_CWDDIR") + "SAMPLE2.INF"
        !            67:     END IF
        !            68:     ReadInfFile szInf$
        !            69: 
        !            70:     WINDRIVE$ = MID$(GetWindowsDir, 1, 1)
        !            71:     DEST$ = WINDRIVE$ + ":\DEMO"
        !            72: 
        !            73:     ''CustInst list symbols
        !            74:     CHECKSTATES$ = "CheckItemsState"
        !            75:     STATUSTEXT$  = "StatusItemsText"
        !            76:     DRIVETEXT$   = "DriveStatusText"
        !            77:     FOR i% = 1 TO 3 STEP 1
        !            78:         AddListItem CHECKSTATES$, "ON"
        !            79:     NEXT i%
        !            80:     FOR i% = 1 TO 3 STEP 1
        !            81:         AddListItem STATUSTEXT$, ""
        !            82:     NEXT i%
        !            83:     FOR i% = 1 TO 7 STEP 1
        !            84:         AddListItem DRIVETEXT$, ""
        !            85:     NEXT i%
        !            86:     ReplaceListItem DRIVETEXT$, 7, DEST$
        !            87: 
        !            88:     ''Disk cost list symbols
        !            89:     APPNEEDS$   = "AppNeeds"
        !            90:     OPT1NEEDS$  = "Opt1Needs"
        !            91:     OPT2NEEDS$  = "Opt2Needs"
        !            92:     EXTRACOSTS$ = "ExtraCosts"
        !            93:     BIGLIST$    = "BigList"
        !            94:     FOR i% = 1 TO 3 STEP 1
        !            95:         AddListItem BIGLIST$, ""
        !            96:     NEXT i%
        !            97:     FOR i% = 1 TO 26 STEP 1
        !            98:         AddListItem EXTRACOSTS$, "0"
        !            99:     NEXT i%
        !           100: 
        !           101:     ''File Option Variables
        !           102:     OPT1OPT$ = "1"
        !           103:     OPT2OPT$ = "1"
        !           104: 
        !           105:     RecalcPath
        !           106:     SetDriveStatus
        !           107: 
        !           108: '$IFDEF DEBUG
        !           109:     i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
        !           110: '$ENDIF ''DEBUG
        !           111: 
        !           112: 
        !           113: 
        !           114: CUSTINST:
        !           115:     sz$ = UIStartDlg(CUIDLL$, CUSTINST, "FCustInstDlgProc", APPHELP, HELPPROC$)
        !           116: 
        !           117:     IF sz$ = "CONTINUE" THEN
        !           118:         ''Install only if it will fit.
        !           119:         FOR i% = 1 TO 3 STEP 1
        !           120:             IF GetListItem(BIGLIST$, i%) <> "" THEN
        !           121:                 GOSUB TOOBIG
        !           122:                 GOTO CUSTINST
        !           123:             END IF
        !           124:         NEXT i%
        !           125:         UIPop 1
        !           126:         GOTO INSTALL
        !           127:     ELSEIF sz$ = "PATH" THEN
        !           128:         GOTO GETPATH
        !           129:     ELSEIF sz$ = "CHK1" THEN
        !           130:         RecalcOptFiles APPFILES
        !           131:         SetDriveStatus
        !           132:         GOTO CUSTINST
        !           133:     ELSEIF sz$ = "CHK2" THEN
        !           134:         RecalcOptFiles OPTFILES1
        !           135:         SetDriveStatus
        !           136:         GOTO CUSTINST
        !           137:     ELSEIF sz$ = "CHK3" THEN
        !           138:         RecalcOptFiles OPTFILES2
        !           139:         SetDriveStatus
        !           140:         GOTO CUSTINST
        !           141:     ELSEIF sz$ = "BTN2" THEN
        !           142:         GOTO OPTFILES1
        !           143:     ELSEIF sz$ = "BTN3" THEN
        !           144:         GOTO OPTFILES2
        !           145:     ELSEIF sz$ = "REACTIVATE" THEN
        !           146:         RecalcPath
        !           147:         SetDriveStatus
        !           148:         GOTO CUSTINST
        !           149:     ELSE
        !           150:         GOSUB ASKQUIT
        !           151:         GOTO CUSTINST
        !           152:     END IF
        !           153: 
        !           154: 
        !           155: 
        !           156: INSTALL:
        !           157:     ClearCopyList
        !           158:     AddOptFilesToCopyList APPFILES
        !           159:     AddOptFilesToCopyList OPTFILES1
        !           160:     AddOptFilesToCopyList OPTFILES2
        !           161:     CreateDir DEST$, cmoNone
        !           162:     CopyFilesInCopyList
        !           163: 
        !           164:     IF GetListItem(CHECKSTATES$, OPTFILES1) = "ON" THEN
        !           165:         ini$ = MakePath(DEST$, "DEMO.INI")
        !           166:         CreateIniKeyValue "WIN.INI", "MSSetup Sample 2", "Option1", OPT1OPT$, cmoNone
        !           167:         CreateIniKeyValue ini$, "Section 1", "Key 1", "Value 1" , cmoNone
        !           168:         CreateIniKeyValue ini$, "Section 2", "Key 2", "Value 2" , cmoNone
        !           169:         CreateIniKeyValue ini$, "Section 3", "Key 3", "Value 3" , cmoNone
        !           170:         ini$ = ""
        !           171:     END IF
        !           172: 
        !           173:     IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
        !           174:         CreateProgmanGroup "MSSetup Sample 2", "", cmoNone
        !           175:         ShowProgmanGroup  "MSSetup Sample 2", 1, cmoNone
        !           176:         CreateProgmanItem "MSSetup Sample 2", "dialogs", "dlgedit.exe "+MakePath(DEST$,"dialogs.res"), "", cmoOverwrite
        !           177:         CreateProgmanItem "MSSetup Sample 2", "dlgprocs.c", "notepad.exe "+MakePath(DEST$,"dlgprocs.c"), "", cmoOverwrite
        !           178:     END IF
        !           179: 
        !           180: 
        !           181: QUIT:
        !           182:     ON ERROR GOTO ERRQUIT
        !           183: 
        !           184:     IF ERR = 0 THEN
        !           185:         dlg% = EXITSUCCESS
        !           186:     ELSEIF ERR = STFQUIT THEN
        !           187:         dlg% = EXITQUIT
        !           188:     ELSE
        !           189:         dlg% = EXITFAILURE
        !           190:     END IF
        !           191: QUITL1:
        !           192:     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
        !           193:     IF sz$ = "REACTIVATE" THEN
        !           194:         GOTO QUITL1
        !           195:     END IF
        !           196:     UIPop 1
        !           197: 
        !           198:     END
        !           199: 
        !           200: ERRQUIT:
        !           201:     i% = DoMsgBox("Setup sources were corrupted, call 555-1212!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
        !           202:     END
        !           203: 
        !           204: 
        !           205: 
        !           206: GETPATH:
        !           207:     SetSymbolValue "EditTextIn", DEST$
        !           208:     SetSymbolValue "EditFocus", "END"
        !           209: GETPATHL1:
        !           210:     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
        !           211: 
        !           212:     IF sz$ = "CONTINUE" THEN
        !           213:         olddest$ = DEST$
        !           214:         DEST$ = GetSymbolValue("EditTextOut")
        !           215: 
        !           216:         ''Validate new path.
        !           217:         IF IsDirWritable(DEST$) = 0 THEN
        !           218:             GOSUB BADPATH
        !           219:             GOTO GETPATHL1
        !           220:         END IF
        !           221:         UIPop 1
        !           222: 
        !           223:         ''Truncate display if too long.
        !           224:         IF LEN(DEST$) > 23 THEN
        !           225:             ReplaceListItem DRIVETEXT$, 7, MID$(DEST$, 1, 23)+"..."
        !           226:         ELSE
        !           227:             ReplaceListItem DRIVETEXT$, 7, DEST$
        !           228:         END IF
        !           229: 
        !           230:         ''Recalc if path changed.
        !           231:         IF (olddest$ <> DEST$) AND (olddest$ <> DEST$+"\") AND (olddest$+"\" <> DEST$) THEN
        !           232:             RecalcPath
        !           233:             SetDriveStatus
        !           234:         END IF
        !           235: 
        !           236:         olddest$ = ""
        !           237:         GOTO CUSTINST
        !           238:     ELSEIF sz$ = "REACTIVATE" THEN
        !           239:         RecalcPath
        !           240:         SetDriveStatus
        !           241:         GOTO GETPATHL1
        !           242:     ELSEIF sz$ = "EXIT" THEN
        !           243:         GOSUB ASKQUIT
        !           244:         GOTO GETPATHL1
        !           245:     ELSE
        !           246:         UIPop 1
        !           247:         GOTO CUSTINST
        !           248:     END IF
        !           249: 
        !           250: 
        !           251: 
        !           252: OPTFILES1:
        !           253:     SetSymbolValue "RadioDefault", OPT1OPT$
        !           254: OPT1L1:
        !           255:     sz$ = UIStartDlg(CUIDLL$, OPTIONS, "FRadioDlgProc", APPHELP, HELPPROC$)
        !           256:     newopt$ = GetSymbolValue("ButtonChecked")
        !           257: 
        !           258:     IF sz$ = "CONTINUE" THEN
        !           259:         UIPop 1
        !           260:         IF newopt$ <> OPT1OPT$ THEN
        !           261:             OPT1OPT$ = newopt$
        !           262:             RecalcOptFiles OPTFILES1
        !           263:             SetDriveStatus
        !           264:         END IF
        !           265:         newopt$ = ""
        !           266:         GOTO CUSTINST
        !           267:     ELSEIF sz$ = "REACTIVATE" THEN
        !           268:         RecalcPath
        !           269:         SetDriveStatus
        !           270:         GOTO OPT1L1
        !           271:     ELSEIF sz$ = "EXIT" THEN
        !           272:         GOSUB ASKQUIT
        !           273:         GOTO OPT1L1
        !           274:     ELSE
        !           275:         UIPop 1
        !           276:         newopt$ = ""
        !           277:         GOTO CUSTINST
        !           278:     END IF
        !           279: 
        !           280: 
        !           281: 
        !           282: OPTFILES2:
        !           283:     SetSymbolValue "RadioDefault", OPT2OPT$
        !           284: OPT2L1:
        !           285:     sz$ = UIStartDlg(CUIDLL$, OPTIONS, "FRadioDlgProc", APPHELP, HELPPROC$)
        !           286:     newopt$ = GetSymbolValue("ButtonChecked")
        !           287: 
        !           288:     IF sz$ = "CONTINUE" THEN
        !           289:         UIPop 1
        !           290:         IF newopt$ <> OPT2OPT$ THEN
        !           291:             OPT2OPT$ = newopt$
        !           292:             RecalcOptFiles OPTFILES2
        !           293:             SetDriveStatus
        !           294:         END IF
        !           295:         newopt$ = ""
        !           296:         GOTO CUSTINST
        !           297:     ELSEIF sz$ = "REACTIVATE" THEN
        !           298:         RecalcPath
        !           299:         SetDriveStatus
        !           300:         GOTO OPT2L1
        !           301:     ELSEIF sz$ = "EXIT" THEN
        !           302:         GOSUB ASKQUIT
        !           303:         GOTO OPT2L1
        !           304:     ELSE
        !           305:         UIPop 1
        !           306:         newopt$ = ""
        !           307:         GOTO CUSTINST
        !           308:     END IF
        !           309: 
        !           310: 
        !           311: 
        !           312: TOOBIG:
        !           313:     sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
        !           314:     IF sz$ = "REACTIVATE" THEN
        !           315:         RecalcPath
        !           316:         SetDriveStatus
        !           317:         GOTO TOOBIG
        !           318:     END IF
        !           319:     UIPop 1
        !           320:     RETURN
        !           321: 
        !           322: 
        !           323: 
        !           324: BADPATH:
        !           325:     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
        !           326:     IF sz$ = "REACTIVATE" THEN
        !           327:         RecalcPath
        !           328:         SetDriveStatus
        !           329:         GOTO BADPATH
        !           330:     END IF
        !           331:     UIPop 1
        !           332:     RETURN
        !           333: 
        !           334: 
        !           335: 
        !           336: ASKQUIT:
        !           337:     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
        !           338: 
        !           339:     IF sz$ = "EXIT" THEN
        !           340:         UIPopAll
        !           341:         ERROR STFQUIT
        !           342:     ELSEIF sz$ = "REACTIVATE" THEN
        !           343:         GOTO ASKQUIT
        !           344:     ELSE
        !           345:         UIPop 1
        !           346:     END IF
        !           347:     RETURN
        !           348: 
        !           349: 
        !           350: 
        !           351: '**
        !           352: '** Purpose:
        !           353: '**     Adds the specified option files to the copy list.
        !           354: '** Arguments:
        !           355: '**     ftype%  - type of files to add, one of the following:
        !           356: '**             APPFILES, OPTFILES1, OPTFILES2
        !           357: '** Returns:
        !           358: '**     none.
        !           359: '*************************************************************************
        !           360: SUB AddOptFilesToCopyList (ftype%) STATIC
        !           361: 
        !           362:     IF GetListItem(CHECKSTATES$, ftype%) = "ON" THEN
        !           363:         SrcDir$ = GetSymbolValue("STF_SRCDIR")
        !           364:         IF ftype% = APPFILES THEN
        !           365:             AddSectionFilesToCopyList "AppFiles", SrcDir$, DEST$
        !           366:         ELSEIF ftype% = OPTFILES1 THEN
        !           367:             AddSectionKeyFileToCopyList "OptFiles1", OPT1OPT$, SrcDir$, DEST$
        !           368:         ELSEIF ftype% = OPTFILES2 THEN
        !           369:             AddSectionKeyFileToCopyList "OptFiles2", OPT2OPT$, SrcDir$, DEST$
        !           370:         END IF
        !           371:         SrcDir$ = ""
        !           372:     END IF
        !           373: END SUB
        !           374: 
        !           375: 
        !           376: '**
        !           377: '** Purpose:
        !           378: '**     Recalculates disk space for the given option files and sets
        !           379: '**     the status info symbol "StatusItemsText".
        !           380: '** Arguments:
        !           381: '**     ftype% - type of files to add, one of the following:
        !           382: '**             APPFILES, OPTFILES1, OPTFILES2
        !           383: '** Returns:
        !           384: '**     none.
        !           385: '*************************************************************************
        !           386: SUB RecalcOptFiles (ftype%) STATIC
        !           387:     CursorSave% = ShowWaitCursor()
        !           388:     ClearCopyList
        !           389:     AddOptFilesToCopyList ftype%
        !           390: 
        !           391:     fExtra% = 0
        !           392:     IF ftype% = APPFILES THEN
        !           393:         ListSym$ = APPNEEDS$
        !           394:         IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
        !           395:             ''Add extra cost to Windows drive for ini/progman, etc.
        !           396:             ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
        !           397:             ReplaceListItem EXTRACOSTS$, ndrive%, "10240"
        !           398:             fExtra% = 1
        !           399:         END IF
        !           400:     ELSEIF ftype% = OPTFILES1 THEN
        !           401:         ListSym$ = OPT1NEEDS$
        !           402:     ELSEIF ftype% = OPTFILES2 THEN
        !           403:         ListSym$ = OPT2NEEDS$
        !           404:     END IF
        !           405: 
        !           406:     StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "")
        !           407: 
        !           408:     cost& = 0
        !           409:     FOR i% = 1 TO 26 STEP 1
        !           410:         cost&  = cost& + VAL(GetListItem(ListSym$, i%))
        !           411:     NEXT i%
        !           412:     ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024) + " K"
        !           413: 
        !           414:     IF StillNeed& > 0 THEN
        !           415:         ReplaceListItem BIGLIST$, ftype%, "YES"
        !           416:     ELSE
        !           417:         ReplaceListItem BIGLIST$, ftype%, ""
        !           418:     END IF
        !           419: 
        !           420:     IF fExtra% THEN
        !           421:         ReplaceListItem EXTRACOSTS$, ndrive%, "0"
        !           422:     END IF
        !           423:     RestoreCursor CursorSave%
        !           424:     ListSym$ = ""
        !           425: END SUB
        !           426: 
        !           427: 
        !           428: '**
        !           429: '** Purpose:
        !           430: '**     Recalculates disk space and sets option status info according
        !           431: '**     to the current destination path.
        !           432: '** Arguments:
        !           433: '**     none.
        !           434: '** Returns:
        !           435: '**     none.
        !           436: '*************************************************************************
        !           437: SUB RecalcPath STATIC
        !           438: 
        !           439:     CursorSave% = ShowWaitCursor()
        !           440: 
        !           441:     RecalcOptFiles APPFILES
        !           442:     RecalcOptFiles OPTFILES1
        !           443:     RecalcOptFiles OPTFILES2
        !           444: 
        !           445:     RestoreCursor CursorSave%
        !           446: END SUB
        !           447: 
        !           448: 
        !           449: '**
        !           450: '** Purpose:
        !           451: '**     Sets drive status info according to latest disk space calcs.
        !           452: '** Arguments:
        !           453: '**     none.
        !           454: '** Returns:
        !           455: '**     none.
        !           456: '*************************************************************************
        !           457: SUB SetDriveStatus STATIC
        !           458: 
        !           459:     drive$ = MID$(DEST$, 1, 1)
        !           460:     ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1
        !           461:     cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(OPT1NEEDS$, ndrive%)) + VAL(GetListItem(OPT2NEEDS$, ndrive%))
        !           462:     free& = GetFreeSpaceForDrive(drive$)
        !           463:     ReplaceListItem DRIVETEXT$, 1, drive$ + ":"
        !           464:     ReplaceListItem DRIVETEXT$, 2, STR$(cost& / 1024) + " K"
        !           465:     ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " K"
        !           466: 
        !           467:     IF drive$ = WINDRIVE$ THEN
        !           468:         ReplaceListItem DRIVETEXT$, 4, ""
        !           469:         ReplaceListItem DRIVETEXT$, 5, ""
        !           470:         ReplaceListItem DRIVETEXT$, 6, ""
        !           471:     ELSE
        !           472:         ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
        !           473:         cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(OPT1NEEDS$, ndrive%)) + VAL(GetListItem(OPT2NEEDS$, ndrive%))
        !           474:         IF cost& = 0 THEN
        !           475:             ReplaceListItem DRIVETEXT$, 4, ""
        !           476:             ReplaceListItem DRIVETEXT$, 5, ""
        !           477:             ReplaceListItem DRIVETEXT$, 6, ""
        !           478:         ELSE
        !           479:             free& = GetFreeSpaceForDrive(WINDRIVE$)
        !           480:             ReplaceListItem DRIVETEXT$, 4, WINDRIVE$ + ":"
        !           481:             ReplaceListItem DRIVETEXT$, 5, STR$(cost& / 1024) + " K"
        !           482:             ReplaceListItem DRIVETEXT$, 6, STR$(free& / 1024) + " K"
        !           483:         END IF
        !           484:     END IF
        !           485: END SUB
        !           486: 
        !           487: 
        !           488: '**
        !           489: '** Purpose:
        !           490: '**     Appends a file name to the end of a directory path,
        !           491: '**     inserting a backslash character as needed.
        !           492: '** Arguments:
        !           493: '**     szDir$  - full directory path (with optional ending "\")
        !           494: '**     szFile$ - filename to append to directory
        !           495: '** Returns:
        !           496: '**     Resulting fully qualified path name.
        !           497: '*************************************************************************
        !           498: FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
        !           499:     IF szDir$ = "" THEN
        !           500:         MakePath = szFile$
        !           501:     ELSEIF szFile$ = "" THEN
        !           502:         MakePath = szDir$
        !           503:     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
        !           504:         MakePath = szDir$ + szFile$
        !           505:     ELSE
        !           506:         MakePath = szDir$ + "\" + szFile$
        !           507:     END IF
        !           508: END FUNCTION
        !           509: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.