home *** CD-ROM | disk | FTP | other *** search
- '' ---------------------------------------------------------------------
- ''
- '' Double Doozy Setup
- ''
- '' ---------------------------------------------------------------------
-
- '' '$define DEBUG ''Define for script development/debugging
-
- '' ---------------------------------------------------------------------
-
- '$include 'setupapi.inc'
- '$include 'msdetect.inc'
-
- '' ---------------------------------------------------------------------
-
- '' Resource ID's
- CONST IDICN_SETUP = 6000
- CONST IDBMP_LOGO = 6100
-
- '' Custom Dialog IDs
- CONST IDDLG_WELCOME = 100
- CONST IDDLG_ASKQUIT = 200
- CONST IDDLG_DESTPATH = 300
- CONST IDDLG_EXITQUIT = 400
- CONST IDDLG_EXITSUCCESS = 500
- CONST IDDLG_NODISKSPACE = 600
- CONST IDDLG_SELECTOPTIONS = 700
-
- '' Custom user interface dll
- CONST CUIDLL$ = "cui.dll"
-
- '' ---------------------------------------------------------------------
-
- '' Default destination directory.
- GLOBAL DEST$
-
- '' Options
- GLOBAL OptScreenSavers%
- GLOBAL OptWallPapers%
- GLOBAL OptIcons%
-
- '' Section names, case sensitive: any files without a section go under "Files"
- CONST ProgramKey$ = "doozy"
- CONST WallPaperKey$ = "wallpaper"
- CONST IconKey$ = "icon"
- CONST FontKey$ = "font"
-
- '' ---------------------------------------------------------------------
-
- '' Font installation functions
- DECLARE FUNCTION CreateScalableFontResource LIB "gdi" (fHidden%, szDestFontName$, szFontFile$, szFontFilePath$) AS INTEGER
- DECLARE FUNCTION AddFontResource LIB "gdi" (szDestFontName$) AS INTEGER
- DECLARE FUNCTION SendMessage LIB "user" (hwnd%, uMsg%, wParam%, lParam&) AS LONG
-
- CONST HWND_BROADCAST = 65535 '' 0xffff
- CONST WM_FONTCHANGE = 29 '' 0x001D
-
- '' My DLL functions
- DECLARE FUNCTION CountSectionSizes LIB "cui.dll" (section$, keylistname$) AS LONG
- DECLARE FUNCTION IsStringInFile LIB "cui.dll" (lpszFilename$, lpszString$) AS INTEGER
-
- '' Local function declarations
- DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
- DECLARE SUB BuildCopyList
- DECLARE SUB Install
- DECLARE SUB AskQuit
- DECLARE SUB AddGroupItem (szGroup$, szTitle$, ProgName$)
-
- '' ---------------------------------------------------------------------
-
- '' Lets do an installation ...
- INIT:
- ON ERROR GOTO QUIT
-
- '' Some standard setup stuff
- SetBitmap CUIDLL$, IDBMP_LOGO
- SetTitle "Double Doozy Setup"
-
- '' Make a complete path to the INF file
- szInf$ = GetSymbolValue("STF_SRCINFPATH")
- IF szInf$ = "" THEN
- szInf$ = GetSymbolValue("STF_CWDDIR") + "DOOZY.INF"
- END IF
-
- '' Read in the INF file
- ReadInfFile szInf$
-
- '' Screen savers go in the windows directory
- DEST$ = GetWindowsDir()
-
- '' Default: select all options
- OptScreenSavers% = 1
- OptWallPapers% = 1
- OptIcons% = 1
-
- ''FOR i% = 1 TO 3 STEP 1
- '' AddListItem CHECKSTATES$, "ON"
- ''NEXT i%
-
- '$ifdef DEBUG
- i% = SetSizeCheckMode(scmOnIgnore)
- '$else
- i% = SetSizeCheckMode(scmOnFatal)
- '$endif
-
-
- WELCOME:
- sz$ = UIStartDlg(CUIDLL$, IDDLG_WELCOME, "FDlgProc", 0, "")
- IF sz$ = "CONTINUE" THEN
- UIPop 1
- ELSEIF sz$ = "REACTIVATE" THEN
- GOTO WELCOME
- ELSE
- ASKQUIT
- GOTO WELCOME
- END IF
-
-
- SELECTOPTIONS:
- '' Space needed
- Bytes& = CountSectionSizes&(ProgramKey$, "") + CountSectionSizes&(FontKey$, "")
- SetSymbolValue "Text1", STR$(Bytes& / 1024) + "K"
-
- Bytes& = CountSectionSizes&(WallPaperKey$, "")
- SetSymbolValue "Text2", STR$(Bytes& / 1024) + "K"
-
- Bytes& = CountSectionSizes&(IconKey$, "")
- SetSymbolValue "Text3", STR$(Bytes& / 1024) + "K"
-
- '' Check the options
- SetSymbolValue "CheckItemsIn", ""
- IF OptScreenSavers% = 1 THEN
- AddListItem "CheckItemsIn", "ON"
- ELSE
- AddListItem "CheckItemsIn", "OFF"
- END IF
-
- IF OptWallPapers% = 1 THEN
- AddListItem "CheckItemsIn", "ON"
- ELSE
- AddListItem "CheckItemsIn", "OFF"
- END IF
-
- IF OptIcons% = 1 THEN
- AddListItem "CheckItemsIn", "ON"
- ELSE
- AddListItem "CheckItemsIn", "OFF"
- END IF
-
- SELECTOPTIONS1:
- '' Run the dialog
- sz$ = UIStartDlg(CUIDLL$, IDDLG_SELECTOPTIONS, "FDlgProc", 0, "")
- IF sz$ = "CONTINUE" OR sz$ = "BACK" THEN
-
- '' Retrieve the options
- IF GetListItem("CheckItemsOut", 1) = "ON" THEN
- OptScreenSavers% = 1
- ELSE
- OptScreenSavers% = 0
- END IF
-
- IF GetListItem("CheckItemsOut", 2) = "ON" THEN
- OptWallPapers% = 1
- ELSE
- OptWallPapers% = 0
- END IF
-
- IF GetListItem("CheckItemsOut", 3) = "ON" THEN
- OptIcons% = 1
- ELSE
- OptIcons% = 0
- END IF
-
- UIPop 1
-
- IF sz$ = "BACK" THEN
- GOTO WELCOME
- END IF
-
- ELSEIF sz$ = "REACTIVATE" THEN
- GOTO SELECTOPTIONS1
- ELSE
- ASKQUIT
- GOTO SELECTOPTIONS
- END IF
-
- '' Like it says
- BuildCopyList
-
- RECALC:
- '' Check the amount of space needed
- StillNeed& = GetCopyListCost("ExtraCostsList", "CostCostsList", "NeededCostsList")
- IF StillNeed& <> 0 THEN
- SPACE_CHECK_DLG:
- '' Space required
- SetSymbolValue "Text1", STR$(StillNeed& / 1024) + "K"
-
- '' Space available
- Bytes& = GetFreeSpaceForDrive(Mid$(DEST$, 1, 1))
- SetSymbolValue "Text2", STR$(Bytes& / 1024) + "K"
-
- SPACE_CHECK_DLG1:
- sz$ = UIStartDlg(CUIDLL$, IDDLG_NODISKSPACE, "FDlgProc", 0, "")
- IF sz$ = "CONTINUE" THEN
- UIPop 1
- GOTO SELECTOPTIONS
- ELSEIF sz$ = "REACTIVATE" THEN
- GOTO RECALC
- ELSE
- ASKQUIT
- GOTO SPACE_CHECK_DLG
- END IF
- ENDIF
-
- '' Perform the installation
- Install
-
-
- QUIT:
- IF ERR = 0 THEN
- dlg% = IDDLG_EXITSUCCESS
- ELSEIF ERR = STFQUIT THEN
- dlg% = IDDLG_EXITQUIT
- ELSE
- dlg% = IDDLG_EXITQUIT
- END IF
-
- QUITL1:
- SetSymbolValue "Text1", ""
- SetSymbolValue "Text2", ""
- sz$ = UIStartDlg(CUIDLL$, dlg%, "FDlgProc", 0, "")
- IF sz$ = "REACTIVATE" THEN
- GOTO QUITL1
- END IF
- UIPop 1
-
- END
-
- '' ---------------------------------------------------------------------
-
- SUB BuildCopyList STATIC
-
- SrcDir$ = GetSymbolValue("STF_SRCDIR")
-
- ClearCopyList
-
- IF OptScreenSavers% = 1 THEN
-
- '' Add all screen savers
- AddSectionFilesToCopyList ProgramKey$, SrcDir$, DEST$
-
- '' Install the font only if NOT there ...
- '' The font should be in the system directory.
- szDestFontName$ = MakePath$(GetWindowsSysDir, "doozy.fot")
- IF DoesFileExist(szDestFontName$, femExists) = 0 THEN
- AddSectionFilesToCopyList FontKey$, SrcDir$, GetWindowsSysDir
- END IF
-
- END IF
-
- IF OptWallPapers% = 1 THEN
- AddSectionFilesToCopyList WallPaperKey$, SrcDir$, DEST$
- END IF
-
- IF OptIcons% = 1 THEN
- AddSectionFilesToCopyList IconKey$, SrcDir$, DEST$
- END IF
-
- END SUB
-
- '' ---------------------------------------------------------------------
- '**
- '** Purpose:
- '** Builds the copy list and performs all installation operations.
- '** Arguments:
- '** none.
- '** Returns:
- '** none.
- '*************************************************************************
-
- SUB Install STATIC
-
- SrcDir$ = GetSymbolValue("STF_SRCDIR")
- CreateDir DEST$, cmoNone
-
- ClearBillboardList
- CopyFilesInCopyList
-
- hCursor% = ShowWaitCursor()
-
- IF OptScreenSavers% = 1 THEN
-
- '' The font will be in the system directory at this point.
- szDestFontName$ = MakePath$(GetWindowsSysDir, "doozy.fot")
-
- '' Install the font
- i% = CreateScalableFontResource(0, szDestFontName$, "doozy.ttf", GetWindowsSysDir)
- '$ifdef DEBUG
- if i% = 0 THEN
- i% = DoMsgBox("Error creating the font " + szDestFontName$ + ".", "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
- end if
- '$endif DEBUG
-
- i% = AddFontResource(szDestFontName$)
- '$ifdef DEBUG
- if i% = 0 THEN
- i% = DoMsgBox("Error adding the font " + szDestFontName$, "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
- end if
- '$endif DEBUG
- lRet& = SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0)
-
-
- '' Create a video toys group
- grp$ = "Video Toys"
- CreateProgmanGroup grp$, "", cmoNone
-
- '' Place the order form file in the group window
- IF IsStringInFile(MakePath$(DEST$, "videotoy.grp"), "orderfrm.wri") = 0 THEN
- CreateProgmanItem grp$, "Order Form", "write.exe " + MakePath$(DEST$, "orderfrm.wri"), "", cmoOverwrite
- END IF
-
- '' Add all the screen savers to the group (Alphabetized)
- AddGroupItem grp$, "Aerobics", "aerobics.scr"
- AddGroupItem grp$, "Artist", "artist.scr"
- AddGroupItem grp$, "Children's Story", "kids.scr"
- AddGroupItem grp$, "Deadhead", "deadhead.scr"
- AddGroupItem grp$, "Graffiti", "graffiti.scr"
- AddGroupItem grp$, "Greyhound", "gryhound.scr"
- AddGroupItem grp$, "Hen", "hen.scr"
- AddGroupItem grp$, "Magician", "magician.scr"
- AddGroupItem grp$, "Oops!", "crash.scr"
- AddGroupItem grp$, "Paranoid", "paranoid.scr"
- AddGroupItem grp$, "Pig", "pig.scr"
- AddGroupItem grp$, "Poet", "poetry.scr"
- AddGroupItem grp$, "Rock 'n' Roller", "rocker.scr"
- AddGroupItem grp$, "Shocked", "shocked.scr"
- AddGroupItem grp$, "Skateboarder", "skatebrd.scr"
- AddGroupItem grp$, "Snails", "snails.scr"
- AddGroupItem grp$, "Streaker", "streaker.scr"
- AddGroupItem grp$, "Teeth Cleaner", "teeth.scr"
- AddGroupItem grp$, "Telephone Talker", "chat.scr"
- AddGroupItem grp$, "Yes-Man", "yesman.scr"
-
- '' Display the group window
- ShowProgmanGroup grp$, 1, cmoNone
-
- END IF
-
- RestoreCursor hCursor%
-
- 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
-
- '' ---------------------------------------------------------------------
-
- '**
- '** Ask the user if they want to quit.
- '**
-
- SUB AskQuit STATIC
-
- _ASKQUIT:
- sz$ = UIStartDlg(CUIDLL$, IDDLG_ASKQUIT, "FDlgProc", 0, "")
-
- IF sz$ = "EXIT" THEN
- UIPopAll
- ERROR STFQUIT
- ELSEIF sz$ = "REACTIVATE" THEN
- GOTO _ASKQUIT
- ELSE
- UIPop 1
- END IF
-
- END SUB
-
- '' ---------------------------------------------------------------------
-
- '**
- '** Add the given item to the video toys group if the item is
- '** not there yet.
- '**
- '** Pass the items title and the screen savers disk file name.
- '**
-
- SUB AddGroupItem (szGroup$, szTitle$, ProgName$) STATIC
-
- IF IsStringInFile(MakePath$(DEST$, "videotoy.grp"), ProgName$) = 0 THEN
- runscr$ = MakePath$(DEST$, "runscr.exe")
- CreateProgmanItem szGroup$, szTitle$, runscr$ + " " + ProgName$ + " /s", ProgName$ + ",,,,", cmoOverwrite
- END IF
-
- END SUB
-
- '' ---------------------------------------------------------------------
-