rem ---------------------------------------------------------------------
rem
rem SETUP.MST    - MSSETUP Installation Script
rem
rem                Version 2.0
rem
rem                (c) Copyright 1988-1994 Apple Computer, Inc. All Rights Reserved.
rem
rem                Revised: 12 October 1994
rem                Tony Knight, Apple Computer
rem ---------------------------------------------------------------------


rem Required includes to interface with MSSETUP DLL's
rem -------------------------------------------------
'$INCLUDE 'setupapi.inc'
'$INCLUDE 'msdetect.inc'


rem Dialog box id's
rem ---------------
rem Note: If MSSETUP were really smart, we could use the
rem #defines in DIALOGS.HR. Instead, we must manually
rem keep them in step
rem ----------------------------------------------------
    CONST NUKEOLD       = 101          ''  WARNING FOR OLDER VERSIONS
    CONST OLDMESS       = 102          '' MODELESS DIALOGUE BOX FOR OLDER VERSIONS
    CONST DESTPATH      = 300          ''Gets destination path
    CONST EXITQUIT      = 600          ''Exits on user request
    CONST EXITSUCCESS   = 700          ''Exits when install is done
    CONST OPTIONS       = 800          ''Gets AUTOEXEC.BAT options
    CONST ASKSETUP      = 1100         ''Gets installation type (Local etc)
    CONST TOOBIG        = 6300         ''Not enough space on target disk error
    CONST BADPATH       = 6400         ''Bad destination path error
    CONST BADWINDOWS    = 6500         ''Wrong Windows release
    CONST EXITFAILURE   = 6600         ''Exits on error


rem String id's
rem -----------
rem Note: If MSSETUP were really smart, we could use the
rem #defines in DIALOGS.HR. Instead, we must manually
rem keep them in step
rem ----------------------------------------------------
    CONST STR_PLAYER    = 1024         ''Movie Player
    CONST STR_VIEWER    = 1025         ''Picture Viewer
    CONST STR_GROUP     = 1026         ''Program Manager group
    CONST STR_TITLE     = 1027         ''Installer Title
    CONST STR_MSG1      = 1028         ''Version error message part 1
    CONST STR_MSG2      = 1029         ''Version error message part 2
    CONST STR_MSG3      = 1030         ''Remove obsolete files?
    CONST STR_WARNING   = 1031         ''Warning
    CONST STR_HELP      = 1032         ''Help
    CONST STR_SAMPLE    = 1033         ''Sample movie


rem Miscellaneous Constants
rem -----------------------
    CONST NOLOGO = 1                   ''Dummy NULL bitmap (must be 1)
    CONST LOGO = 2                     ''Background bitmap
    CONST MOVIE = 2                    ''Movie placeholder bitmap
    CONST NOSPACE = 1                  ''No space to complete install
    CONST INSTALLOK = 2                ''Install completed OK
    CONST INSTALLFAILED =3             ''Install failed for some reason
    CONST FILES_REMOVED = 1
    CONST FILES_SKIPPED = 2

rem Global Variables
rem ----------------
    GLOBAL SOURCE$                     ''Source directory
    GLOBAL DEST$                       ''Default destination directory
    GLOBAL DEST2$                       '' DEST FOR WINDOWS QTW .EXE'S
    GLOBAL DEST3$                       '' DEST FOR DOCUMENTATION AND INTERFACES
    GLOBAL LOCALINST$                  ''Local install
    GLOBAL CLIENTINST$                 ''Client install
    GLOBAL SERVERINST$                 ''Server install
    GLOBAL SETUPPATH$                  ''Setup destination path
    GLOBAL SETUPTYPE$                  ''local,client,server
    GLOBAL EXTRACOSTS$                 ''List of extra costs to add per drive
    GLOBAL APPNEEDS$                   ''Disk space costs per drive
    GLOBAL SECTIONKEY$                 ''INF file section key
    GLOBAL SUCCESS%                    ''Installation completion code

    GLOBAL CUIDLL$                     ''User interface DLL
    GLOBAL HELPPROC$                   ''Help dialog procedure


rem Initialize global vriables
rem --------------------------
    SOURCE$         = GetSymbolValue("STF_SRCDIR")
    DEST$           = GetWindowsSysDir
    DEST2$          = GetWindowsDir
    DEST3$          = "C:\QTW"
    LOCALINST$      = "1"
    CLIENTINST$     = "2"
    SERVERINST$     = "3"
    SETUPPATH$      = DEST$
    SETUPTYPE$      = LOCALINST$
    APPNEEDS$       = "AppNeeds"
    EXTRACOSTS$     = "ExtraCosts"
    SECTIONKEY$     = "SectionKey"
    SUCCESS%        = INSTALLFAILED

    FOR i% = 1 TO 26 STEP 1
        AddListItem EXTRACOSTS$, "16384"
    NEXT i%

    rem
    rem default dest to first hard drive
    rem since some OEM systems don't start at C:
    rem
    GetLocalHardDrivesList "HardDrives"
    NumDrives% = GetListLength("HardDrives")

    IF (NUMDRIVES% > 0) THEN
        DEST3$ = GetListItem("HardDrives",1) + ":\QTW"
    END IF

rem Get name of localized user interface dialogs
rem --------------------------------------------
    CUIDLL$ = "SETUP"+GetIniKeyString("WIN.INI", "intl", "sLanguage")+".DLL"
    IF DoesFileExist(CUIDLL$, femExists) = 0 THEN
       CUIDLL$ = "SETUPENU.DLL"
    END IF


rem Subroutines and Functions
rem -------------------------
    DECLARE FUNCTION Install AS INTEGER
    DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
    DECLARE FUNCTION GetQTWVersion LIB "setupenu.dll" (szDLL$) AS INTEGER
    DECLARE FUNCTION GetResourceString LIB "setupenu.dll" (szResource$, idString%) AS INTEGER
    DECLARE FUNCTION StartCustomSetup LIB "setupenu.dll" (hinst%, hwnd%) AS INTEGER
    DECLARE FUNCTION StopCustomSetup LIB "setupenu.dll" (hinst%, hwnd%) AS INTEGER
    DECLARE FUNCTION WritePrivateProfileString LIB "krnl386.exe" (szSect$, szEntry$, szString$, szINI$) AS INTEGER
    DECLARE FUNCTION CheckForOld AS INTEGER
    DECLARE FUNCTION RemoveOldQTFiles (FilePath$) AS INTEGER
    DECLARE FUNCTION CheckForSpace (DrivePath$) AS INTEGER

rem Initialize custom setup logic
rem -----------------------------
    SetBitmap CUIDLL$, NOLOGO
    i% = GetResourceString (CUIDLL$, STR_TITLE)
    SetTitle GetSymbolValue ("ResourceString")
    i% = StartCustomSetup (HinstFrame(), HwndFrame ())
    i% = SetBeepingMode(1)

rem Make sure that we are running on Windows 3.1 or better
rem ------------------------------------------------------
    IF GetWindowsMajorVersion() < 3 THEN
       sz$ = UIStartDlg(CUIDLL$, BADWINDOWS, "FInfo0DlgProc", 0, "")
       UIPop 1
       GOTO CLEANUP
    END IF

    IF (GetWindowsMajorVersion() = 3) AND (GetWindowsMinorVersion() < 10) THEN
       sz$ = UIStartDlg(CUIDLL$, BADWINDOWS, "FInfo0DlgProc", 0, "")
       UIPop 1
       GOTO CLEANUP
    END IF


rem Make sure that we are running on a 286 or better
rem ------------------------------------------------
    IF GetWinFlags() AND 2 THEN
       sz$ = UIStartDlg(CUIDLL$, BADWINDOWS, "FInfo0DlgProc", 0, "")
       UIPop 1
       GOTO CLEANUP
    END IF

rem -------------------------------------------------------------------
    szInf$ = GetSymbolValue("STF_SRCINFPATH")

    IF szInf$ = "" THEN
       szTemp$ = GetSymbolValue("STF_SRCDIR")
       SPLITPATH szTemp$, drv$, dir$, filename$, ext$
       szInf$ = szTemp$ + "SETUP.INF"
    END IF

    ReadInfFile szInf$


rem Get the setup type: Local, Client or Server
rem -------------------------------------------
ITYPE:
    SetSymbolValue "RadioDefault", SETUPTYPE$

ITYPEL1:
    sz$ = UIStartDlg(CUIDLL$, ASKSETUP, "FRadioDlgProc", 0, "")

    SETUPTYPE$ = GetSymbolValue("ButtonChecked")


    IF sz$ = "CONTINUE" THEN
       UIPop(1)

    ELSEIF sz$ = "REACTIVATE" THEN
       GOTO ITYPEL1

    ELSE
       GOSUB ASKQUIT
       GOTO ITYPE

    END IF

    rem Get the destination path for server install; if it's bad, we display an error
    rem ----------------------------------------------------------------

GETPATH2:
    IF (SETUPTYPE$ = SERVERINST$) THEN
        SetSymbolValue "EditTextIn",DEST3$

        SetSymbolValue "EditFocus","ALL"

        sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", 0, "")
        DEST3$ = GetSymbolValue("EditTextOut")
        UIPop 1

        IF sz$ = "CONTINUE" THEN
            IF IsDirWritable(DEST3$) = 1 THEN
                GOTO INSTALLER
            END IF
        END IF

        IF sz$ = "BACK" THEN
            GOTO ITYPE
        END IF

        IF sz$ = "EXIT" THEN
            GOTO ASKQUIT3
        END IF

        IF IsDirWritable(DEST3$) = 0 THEN
            sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
            UIPop 1
            GOTO GETPATH2
        END IF
    END IF
    GOTO INSTALLER

rem ASKQUIT: The user requested quit; does (s)he really want to?
rem ------------------------------------------------------------
ASKQUIT3:
    sz$ = UIStartDlg(CUIDLL$, EXITQUIT, "FInfoDlgProc", 0, "")
    UIPop 1
    IF sz$ = "CONTINUE" THEN
       GOTO GETPATH2
    END IF
    GOTO CLEANUP


rem Perform actual installation
rem ---------------------------
INSTALLER:
    SUCCESS% = Install

    IF SUCCESS% = NOSPACE THEN
       GOSUB TOOBIG
    END IF


rem When done, issue dialog
rem -----------------------
QUIT:
    IF SUCCESS% = INSTALLOK THEN
       sz$ = UIStartDlg(CUIDLL$, EXITSUCCESS, "FInfo0DlgProc", 0, "")
    ELSE
       sz$ = UIStartDlg(CUIDLL$, EXITFAILURE, "FInfo0DlgProc", 0, "")
    END IF
    UIPop 1


rem Clean up all processing
rem -----------------------
CLEANUP:
    i% = StopCustomSetup (HinstFrame(), HwndFrame ())

    END


rem ASKQUIT: The user requested quit; does (s)he really want to?
rem ------------------------------------------------------------
ASKQUIT:
    sz$ = UIStartDlg(CUIDLL$, EXITQUIT, "FInfoDlgProc", 0, "")
    UIPop 1
    IF sz$ = "CONTINUE" THEN
       RETURN
    END IF
    GOTO CLEANUP


rem BADPATH: The user entered an invalid destination directory
rem ----------------------------------------------------------
BADPATH:
    sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
    IF sz$ = "REACTIVATE" THEN
       GOTO BADPATH
    END IF
    UIPop 1

    RETURN


rem TOOBIG: The source files won't fit on the requested destination disk
rem --------------------------------------------------------------------
TOOBIG:
    sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
    IF sz$ = "REACTIVATE" THEN
       GOTO TOOBIG
    END IF
    UIPop 1

    RETURN

rem Install: Perform actual installation
rem ------------------------------------
FUNCTION Install STATIC AS INTEGER

    ClearCopyList
    rem For Local or Server installs ...
    rem --------------------------------
        IF (SETUPTYPE$ = LOCALINST$) OR (SETUPTYPE$ = CLIENTINST$) THEN
            AddSectionFilesToCopyList "Files", SOURCE$, DEST$
            AddSectionFilesToCopyList "Winexe", SOURCE$, DEST2$
            spaceCheck% = CheckForSpace(DEST$)
            IF (spaceCheck% = NOSPACE) THEN
                Install = NOSPACE
                EXIT FUNCTION
            END IF
            spaceCheck% = CheckForSpace(DEST2$)
            IF (spaceCheck% = NOSPACE) THEN
                Install = NOSPACE
                EXIT FUNCTION
            END IF
        END IF

        IF (SETUPTYPE$ = SERVERINST$) THEN
            AddSectionFilesToCopyList "Files", SOURCE$, DEST3$ + "BIN\"
            AddSectionFilesToCopyList "Winexe", SOURCE$, DEST3$ + "BIN\"
            AddSectionFilesToCopyList "Setup", SOURCE$, DEST3$
rem         AddSectionFilesToCopyList "QTW", SOURCE$, DEST3$
            spaceCheck% = CheckForSpace(DEST3$)
            IF (spaceCheck% = NOSPACE) THEN
                Install = NOSPACE
                EXIT FUNCTION
            END IF
        ELSE 
            j% = CheckForOld()
        END IF

        rem Copy files necessary for installation from server
        rem -------------------------------------------------
        IF SETUPTYPE$ = SERVERINST$ THEN
            CopyFile MakePath(SOURCE$, "SETUP.INF"), MakePath(DEST3$, "SETUP.INF"), cmoOverwrite, 0
            CopyFile MakePath(SOURCE$, "DISK1.ID"), MakePath(DEST3$, "DISK1.ID"), cmoOverwrite, 0
        END IF

        rem Copy all the files from the source to the destination
        rem -----------------------------------------------------

        CopyFilesInCopyList

    rem Update WIN.INI and SYSTEM.INI
    rem -----------------------------
        IF (SETUPTYPE$ = LOCALINST$) OR (SETUPTYPE$ = CLIENTINST$) THEN
           inia$ = MakePath(DEST2$, "WIN.INI")
           inib$ = MakePath(DEST2$, "WIN.QTW")
           CopyFile inia$, inib$, cmoOverwrite, 0
           inia$ = MakePath(DEST2$, "SYSTEM.INI")
           inib$ = MakePath(DEST2$, "SYSTEM.QTW")
           CopyFile inia$, inib$, cmoOverwrite, 0
           CreateIniKeyValue "WIN.INI", "Extensions", "mov", MakePath(DEST2$,"player.exe") + " ^.mov", cmoOverwrite
           CreateIniKeyValue "WIN.INI", "Extensions", "pic", MakePath(DEST2$,"viewer.exe") + " ^.pic", cmoOverwrite
           CreateIniKeyValue "WIN.INI", "MCI Extensions", "mov", "QTWVideo", cmoOverwrite
           CreateIniKeyValue "WIN.INI", "MCI Extensions", "pic", "QTWVideo", cmoOverwrite
           CreateIniKeyValue "WIN.INI", "MCI Extensions", "jpg", "QTWVideo", cmoOverwrite
           i% = WritePrivateProfileString("MCI", "QTWVideo", MakePath(DEST$, "mciqtw.drv"), "SYSTEM.INI")

        rem Compatibility hacks.
           i% = WritePrivateProfileString("Macx", "DeviceBitmap", "OFF", "SYSTEM.INI")
           CreateIniKeyValue "WIN.INI", "Mach", "devicebitmap", "off", cmoOverwrite

        rem Update Registration Database
        rem ----------------------------
           RUN MakePath(DEST2$, "player.exe") + " install"
           RUN MakePath(DEST2$, "viewer.exe") + " install"

        rem Create QTW.INI
        rem ----------------
           ini$ = MakePath(DEST2$, "QTW.INI")
           CreateIniKeyValue ini$, "QuickTime for Windows", "Implementation", "Full" , cmoOverwrite
           RemoveIniKey ini$, "video", "optimize", cmoNone


'***********************************************************************************
rem end of runtime install functionality
rem uncomment the following lines to have a strictly runtime installation script
rem Indicate install completed OK
rem -----------------------------
'       Install = INSTALLOK     ' uncomment this line for runtime only setup
'       EXIT FUNCTION           ' uncomment this line for runtime only setup

'***********************************************************************************

    rem Get the destination path; if it's bad, we display an error
    rem ----------------------------------------------------------------

        SetSymbolValue "EditTextIn",DEST3$

GETPATH1:
        SetSymbolValue "EditFocus","ALL"

        sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", 0, "")
        DEST3$ = GetSymbolValue("EditTextOut")
        UIPop 1

        IF sz$ = "CONTINUE" THEN
            IF IsDirWritable(DEST3$) = 1 THEN
                GOTO DEVINSTALL
            END IF
        END IF

    rem button is labeled "skip" in dialog resource
        IF sz$ = "BACK" THEN
            Install = INSTALLOK
            EXIT FUNCTION
        END IF

        IF sz$ = "EXIT" THEN
            GOTO ASKQUIT2
        END IF


        IF IsDirWritable(DEST3$) = 0 THEN
            sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
            UIPop 1
            GOTO GETPATH1
        END IF



rem ASKQUIT2: The user requested quit; does (s)he really want to?
rem ------------------------------------------------------------
ASKQUIT2:
    sz$ = UIStartDlg(CUIDLL$, EXITQUIT, "FInfoDlgProc", 0, "")
    UIPop 1
    IF sz$ = "CONTINUE" THEN
       GOTO GETPATH1
    END IF

rem Clean up all processing
rem -----------------------
CLEANUP2:
    i% = StopCustomSetup (HinstFrame(), HwndFrame ())

    END


'***************************************************************
REM THIS SECTION COMPLETES THE DEVELOPER INSTALL AND ANNOTATES THE APPROPRIATE INI FILES

DEVINSTALL:


    ClearCopyList

    AddSectionFilesToCopyList "QTW", SOURCE$, DEST3$
    CopyFilesInCopyList

    rem Create a Program Manager group
    rem ------------------------------
           i% = GetResourceString (CUIDLL$, STR_GROUP)
           GROUP$ = GetSymbolValue ("ResourceString")
           CreateProgmanGroup GROUP$, "", cmoNone
           i% = GetResourceString (CUIDLL$, STR_SAMPLE)
           CreateProgmanItem GROUP$, GetSymbolValue ("ResourceString"), MakePath(DEST2$,"player.exe ") + MakePath(DEST3$,"samples\sample.mov"), "", cmoOverwrite
           i% = GetResourceString (CUIDLL$, STR_PLAYER)
           CreateProgmanItem GROUP$, GetSymbolValue ("ResourceString"), MakePath(DEST2$,"player.exe"), "", cmoOverwrite
           i% = GetResourceString (CUIDLL$, STR_VIEWER)
           CreateProgmanItem GROUP$, GetSymbolValue ("ResourceString"), MakePath(DEST2$,"viewer.exe"), "", cmoOverwrite
           i% = GetResourceString (CUIDLL$, STR_HELP)
           CreateProgmanItem GROUP$, GetSymbolValue ("ResourceString"), MakePath(DEST2$, "winhelp.exe ") + MakePath(DEST3$,"help\qtw.hlp"), "", cmoOverwrite
           CreateProgmanItem GROUP$, "Read Me", MakePath(DEST2$,"readme.exe"), "", cmoOverwrite

        END IF

    rem Indicate install completed OK
    rem -----------------------------
        Install = INSTALLOK

END FUNCTION

rem MakePath: Builds path from directory and file
rem ---------------------------------------------
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

rem Check for Older versions of the Quicktime For Windows components
rem ---------------------------------------------------------------
FUNCTION CheckForOld STATIC AS INTEGER

    sz$ = UIStartDlg(CUIDLL$, OLDMESS, "FModelessDlgProc", 0, "")

CheckForOld1:
    cursor% = ShowWaitCursor()
    OldFilePath$ = FindFileUsingFileOpen("qtim.dll")
    RestoreCursor cursor%
    IF (OldFilePath$ <> "") THEN
        j% = RemoveOldQTFiles(OldFilePath$)
        IF j% = FILES_REMOVED THEN
            GOTO CheckForOld1
        END IF
    END IF

CheckForOld2:
    cursor% = ShowWaitCursor()
    OldFilePath$ = FindFileUsingFileOpen("qtimcmgr.dll")
    RestoreCursor cursor%
    IF (OldFilePath$ <> "") THEN
        j% = RemoveOldQTFiles(OldFilePath$)
        IF j% = FILES_REMOVED THEN
            GOTO CheckForOld2
        END IF
    END IF

    GetLocalHardDrivesList "HardDrives"
    NumDrives% = GetListLength("HardDrives")

    IF (NUMDRIVES% > 0) THEN
        FOR i% = 1 TO NumDrives% STEP 1
            CurrentDrive$ = GetListItem("HardDrives",i%) + ":\"
            CheckForOld3:
                cursor% = ShowWaitCursor()
                OldFilePath$ = FindFileInTree("qtim.dll",CurrentDrive$)
                RestoreCursor cursor%
                IF (OldFilePath$ <> "") THEN
                    j% = RemoveOldQTFiles(OldFilePath$)
                    IF j% = FILES_REMOVED THEN
                        GOTO CheckForOld3
                    END IF
                END IF

            CheckForOld4:
                cursor% = ShowWaitCursor()
                OldFilePath$ = FindFileInTree("qtimcmgr.dll",CurrentDrive$)
                RestoreCursor cursor%
                IF (OldFilePath$ <> "") THEN
                    j% = RemoveOldQTFiles(OldFilePath$)
                    IF j% = FILES_REMOVED THEN
                        GOTO CheckForOld4
                    END IF
                END IF
        NEXT i%
    END IF

    UIPOP 1

END FUNCTION

FUNCTION RemoveOldQTFiles (FilePath$) STATIC AS INTEGER

    RemoveOldQTFiles = FILES_SKIPPED

    SPLITPATH FilePath$, drv$, dir$, filename$, ext$
    DeadPath$ = drv$ + dir$

  rem check version resources if they exist
      szVersion$ = GetVersionOfFile(FilePath$)

  rem dialog choices are Remove,Skip ("Continue","Back" buttons)
    SetSymbolValue "EditTextIn", "Found Version [" + szVersion$ + "] on " + DeadPath$
    sz$ = UIStartDlg(CUIDLL$, NUKEOLD, "FEditDlgProc", 0, "")
    UIPop 1

    IF sz$ = "BACK" THEN
        EXIT FUNCTION
    END IF

    IF sz$ <> "CONTINUE" THEN
        EXIT FUNCTION
    END IF

    rem all versions
        RemoveFile MakePath(DeadPath$, "qtim.dll"), cmoForce
        RemoveFile MakePath(DeadPath$, "qtimcmgr.dll"), cmoForce
    rem version 1.0.0
        RemoveFile MakePath(DeadPath$, "qcmc.dll"), cmoForce
        RemoveFile MakePath(DeadPath$, "qtjpeg.dll"), cmoForce
        RemoveFile MakePath(DeadPath$, "qtraw.dll"), cmoForce
        RemoveFile MakePath(DeadPath$, "qtsmc.dll"), cmoForce
        RemoveFile MakePath(DeadPath$, "qtrpza.dll"), cmoForce
        RemoveFile MakePath(DeadPath$, "qtrle.dll"), cmoForce
        RemoveFile MakePath(DeadPath$, "qtcvid.dll"), cmoForce
        RemoveFile MakePath(DeadPath$, "qtrt21.dll"), cmoForce
        RemoveFile MakePath(DeadPath$, "qtvhdw.dll"), cmoForce
    rem version 1.1.x and later
        RemoveFile MakePath(DeadPath$, "mciqtw.drv"), cmoForce
        RemoveFile MakePath(DeadPath$, "qcmc.qtc"), cmoForce
        RemoveFile MakePath(DeadPath$, "qtjpeg.qtc"), cmoForce
        RemoveFile MakePath(DeadPath$, "qtraw.qtc"), cmoForce
        RemoveFile MakePath(DeadPath$, "qtsmc.qtc"), cmoForce
        RemoveFile MakePath(DeadPath$, "qtrpza.qtc"), cmoForce
        RemoveFile MakePath(DeadPath$, "qtrle.qtc"), cmoForce
        RemoveFile MakePath(DeadPath$, "qtcvid.qtc"), cmoForce
        RemoveFile MakePath(DeadPath$, "qtrt21.qtc"), cmoForce
        RemoveFile MakePath(DeadPath$, "navg.qtc"), cmoForce
        RemoveFile MakePath(DeadPath$, "qtiv31.qtc"), cmoForce
    rem version 1.9 and later
        RemoveFile MakePath(DeadPath$, "qtvhdw.qtc"), cmoForce
        RemoveFile MakePath(DeadPath$, "qtyvu9.qtc"), cmoForce
        RemoveFile MakePath(DeadPath$, "qtmsvc.qtc"), cmoForce
        RemoveFile MakePath(DeadPath$, "qtiv32.qtc"), cmoForce
        RemoveFile MakePath(DeadPath$, "qtiyvu9.qtc"), cmoForce
        RemoveFile MakePath(DeadPath$, "qtvhdw.qtc"), cmoForce
        RemoveFile MakePath(DeadPath$, "dhio_dh.qtc"), cmoForce
        RemoveFile MakePath(DeadPath$, "reelmgic.qtc"), cmoForce

    RemoveOldQTFiles = FILES_REMOVED

END FUNCTION

'$IFDEF DEBUG
       IF DoesFileExist(MakePath(DEST$, "bin\qtim.dll"), femExists) = 1 THEN
          szError$ = MakePath(DEST$, "BIN")
          i% = GetResourceString (CUIDLL$, STR_MSG1)
          szError$ = szError$ + GetSymbolValue ("ResourceString")
          i% = GetQTWVersion(MakePath(DEST$, "bin\qtim.dll"))
          szVersion$ = GetSymbolValue ("VersionString")
          szError$ = szError$ + szVersion$
          i% = GetResourceString (CUIDLL$, STR_MSG2)
          szError$ = szError$ + GetSymbolValue ("ResourceString")
          i% = GetResourceString (CUIDLL$, STR_WARNING)
          szCaption$ = GetSymbolValue ("ResourceString")
          i% = DoMsgBox(szError$, szCaption$, 20)
          UIPop 1
          IF i% = 7 THEN
             GOTO GETPATHL1
          END IF
          IF szVersion$ = "1.0.0" THEN
             i% = GetResourceString (CUIDLL$, STR_MSG3)
             szError$ = GetSymbolValue ("ResourceString")
             i% = GetResourceString (CUIDLL$, STR_WARNING)
             szCaption$ = GetSymbolValue ("ResourceString")
             i% = DoMsgBox(szError$, szCaption$, 20)
       END IF
'$ENDIF

FUNCTION CheckForSpace (DrivePath$) STATIC AS INTEGER
    CheckForSpace = 0
    
    rem Check that we have enough free space to perform the install
    rem -----------------------------------------------------------
    ListSym$ = APPNEEDS$
    StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "")

    drive$ = MID$(DrivePath$, 1, 1)
    ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1
    cost& = VAL(GetListItem(APPNEEDS$, ndrive%))
    free& = GetFreeSpaceForDrive(drive$)

    IF cost& >= free& THEN
        CheckForSpace = NOSPACE
    END IF
END FUNCTION
