home *** CD-ROM | disk | FTP | other *** search
/ Allie's Playhouse / allies-playhouse.bin / setup.mst < prev    next >
Text File  |  1993-08-27  |  12KB  |  358 lines

  1. '**************************************************************************
  2. '*              MSSetup Toolkit -- Allie's Playhouse Setup
  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 WELCOME       = 100
  12. CONST ASKQUIT       = 200
  13. CONST DESTPATH      = 300
  14. CONST EXITFAILURE   = 400
  15. CONST EXITQUIT      = 600
  16. CONST EXITSUCCESS   = 700
  17. CONST OPTIONS       = 800
  18. CONST APPHELP       = 900
  19. CONST BADPATH       = 6400
  20.  
  21. ''Bitmap ID
  22. CONST LOGO = 1
  23.  
  24. GLOBAL DEST$        ''Default destination directory.
  25. GLOBAL OPTCUR$      ''Option selection from option dialog.
  26.  
  27. DECLARE SUB Install
  28. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  29.  
  30. INIT:
  31.     CUIDLL$ = "mscuistf.dll"            ''Custom user interface dll
  32.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  33.  
  34.     SetBitmap CUIDLL$, LOGO
  35.     SetTitle "Opcode Interactive"
  36.  
  37.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  38.     IF szInf$ = "" THEN
  39.         szInf$ = GetSymbolValue("STF_CWDDIR") + "SETUP.INF"
  40.     END IF
  41.     ReadInfFile szInf$
  42.  
  43.     OPTCUR$ = "1"
  44.     DEST$ = "C:\ALLIE"
  45.  
  46. '$IFDEF DEBUG
  47.     i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
  48.     WinDrive$ = MID$(GetWindowsDir, 1, 1)
  49.     IF IsDriveValid(WinDrive$) = 0 THEN
  50.         i% = DoMsgBox("Windows drive ('"+WinDrive$+"') is not a valid drive.", "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
  51.         GOTO QUIT
  52.     END IF
  53. '$ENDIF ''DEBUG
  54.  
  55.  
  56. WELCOME:
  57.     sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$)
  58.     IF sz$ = "CONTINUE" THEN
  59.         UIPop 1
  60.     ELSE
  61.         GOSUB ASKQUIT
  62.         GOTO WELCOME
  63.     END IF
  64.  
  65.  
  66. OPTION:
  67.     SetSymbolValue "RadioDefault", OPTCUR$
  68. OPTL1:
  69.     sz$ = UIStartDlg(CUIDLL$, OPTIONS, "FRadioDlgProc", APPHELP, HELPPROC$)
  70.     OPTCUR$ = GetSymbolValue("ButtonChecked")
  71.  
  72.     IF sz$ = "CONTINUE" THEN
  73.         UIPop(1)
  74.     ELSEIF sz$ = "REACTIVATE" THEN
  75.         GOTO OPTL1
  76.     ELSE
  77.         GOSUB ASKQUIT
  78.         GOTO OPTION
  79.     END IF
  80.  
  81.  
  82. GETPATH:
  83.     SetSymbolValue "EditTextIn", DEST$
  84.     SetSymbolValue "EditFocus", "END"
  85. GETPATHL1:
  86.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  87.     DEST$ = GetSymbolValue("EditTextOut")
  88.  
  89.     IF sz$ = "CONTINUE" THEN
  90.         IF IsDirWritable(DEST$) = 0 THEN
  91.             GOSUB BADPATH
  92.             GOTO GETPATHL1
  93.         END IF
  94.         UIPop 1
  95.     ELSEIF sz$ = "REACTIVATE" THEN
  96.         GOTO GETPATHL1
  97.     ELSEIF sz$ = "BACK" THEN
  98.         UIPop 1
  99.         GOTO OPTION
  100.     ELSE
  101.         GOSUB ASKQUIT
  102.         GOTO GETPATH
  103.     END IF
  104.  
  105.     'Check for avail space
  106.     drive$ = MID$(DEST$, 1, 1)
  107.     free& = GetFreeSpaceForDrive(drive$)
  108.     IF OPTCUR$ = "1" THEN
  109.         IF free& < 9180276 THEN
  110.             i% = DoMsgBox("Not enough hard disk free space to install. Please make some room or try the Minimum setup.", "SETUP", MB_TASKMODAL+MB_ICONHAND+MB_OK)
  111.             GOSUB OPTION
  112.         END IF
  113.         
  114.     ELSEIF OPTCUR$ = "2" THEN
  115.         IF free& < 1000000 THEN
  116.             i% = DoMsgBox("Not enough hard disk free space to install. Please make some room and try again.", "SETUP", MB_TASKMODAL+MB_ICONHAND+MB_OK)
  117.             GOSUB OPTION
  118.         END IF
  119.     END IF
  120.  
  121.     Install
  122.  
  123.  
  124. QUIT:
  125.     ON ERROR GOTO ERRQUIT
  126.  
  127.     IF ERR = 0 THEN
  128.         IF needAnim$ = "yes" THEN
  129.                 i% = DoMsgBox("Please restart Windows to activate the animation driver after Setup is completed.", "SETUP", MB_TASKMODAL+MB_ICONHAND+MB_OK)
  130.         END IF
  131.         dlg% = EXITSUCCESS
  132.     ELSEIF ERR = STFQUIT THEN
  133.         dlg% = EXITQUIT
  134.     ELSE
  135.         dlg% = EXITFAILURE
  136.     END IF
  137. QUITL1:
  138.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  139.     IF sz$ = "REACTIVATE" THEN
  140.         GOTO QUITL1
  141.     END IF
  142.     UIPop 1
  143.  
  144.     END
  145.  
  146. ERRQUIT:
  147.     i% = DoMsgBox("Setup sources were corrupted, call 555-1212!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  148.     END
  149.  
  150.  
  151.  
  152. BADPATH:
  153.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  154.     IF sz$ = "REACTIVATE" THEN
  155.         GOTO BADPATH
  156.     END IF
  157.     UIPop 1
  158.     RETURN
  159.  
  160. 'TOOBIG:
  161. '    sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
  162. '    IF sz$ = "REACTIVATE" THEN
  163. '       GOTO TOOBIG
  164. '    END IF
  165. '    UIPop 1
  166. '    RETURN
  167.  
  168. ASKQUIT:
  169.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  170.  
  171.     IF sz$ = "EXIT" THEN
  172.         UIPopAll
  173.         ERROR STFQUIT
  174.     ELSEIF sz$ = "REACTIVATE" THEN
  175.         GOTO ASKQUIT
  176.     ELSE
  177.         UIPop 1
  178.     END IF
  179.     RETURN
  180.  
  181.  
  182.  
  183. '**
  184. '** Purpose:
  185. '**     Builds the copy list and performs all installation operations.
  186. '** Arguments:
  187. '**     none.
  188. '** Returns:
  189. '**     none.
  190. '*************************************************************************
  191. SUB Install STATIC
  192.  
  193.  
  194.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  195.     CreateDir DEST$, cmoNone
  196.  
  197.     OpenLogFile MakePath(DEST$, "LOGFILE.OUT"), 0
  198.     WriteToLogFile ""
  199.     WriteToLogFile "  User chose as destination directory: '" + DEST$ + "'"
  200.     WriteToLogFile "  User chose option: '" + OPTCUR$ + "'"
  201.     WriteToLogFile ""
  202.     WriteToLogFile "May have had to create the directory: " + DEST$
  203.     WriteToLogFile ""
  204.  
  205.     ''This detects the MMP drivers and/or installs it
  206.     WinDir$ = getWindowsDir()
  207.     sysDir$ = getWindowsSysDir()
  208.     anim% = DoesIniKeyExist(winDir$ + "system.ini","MCI","Animation")
  209.     animNum% = 0
  210.     IF anim% = 0 THEN
  211.         CreateIniKeyValue winDir$ + "system.ini","mci","animation", "mcimmp.drv", cmoOverwrite
  212.         CreateIniKeyValue "win.ini","mci extensions","mmm","animation", cmoOverwrite
  213.         needAnim$ = "yes"
  214.          
  215.     ELSE
  216.         FOR i% = 1 to 10 STEP 1
  217.              LineExist% = DoesIniKeyExist(winDir$ + "system.ini","MCI","Animation"+str$(i%))
  218.              IF LineExist% = 1 THEN
  219.                   drv$ = GetIniKeyString(winDir$ + "system.ini","MCI","Animation"+str$(i%))
  220.                   IF drv$ = "mcimmp.drv" THEN
  221.                         found$ = "true"
  222.                         IF animNum% = 0 THEN
  223.                               animNum% = i%
  224.                         END IF
  225.                   END IF
  226.              ELSE
  227.                   IF avail$ = "" THEN
  228.                         avail$ = str$(i%)
  229.                         IF animNum% = 0 THEN
  230.                               animNum% = i%
  231.                         END IF
  232.                   END IF
  233.              END IF
  234.         NEXT i%
  235.         IF found$ <> "true" THEN
  236.              CreateIniKeyValue winDir$ + "system.ini", "mci", "Animation"+avail$, "mcimmp.drv", cmoOverwrite
  237.              CreateIniKeyValue "win.ini","mci extensions", "mmm","animation"+avail$, cmoOverwrite
  238.              needAnim$ = "yes"  
  239.         END IF
  240.     END IF
  241.     ''make sure the mci extension setting is OK
  242.     mciExt$ = GetIniKeyString(winDir$ + "win.ini","mci extensions","mmm")
  243.         
  244.     IF mciExt$ <> ("animation" + str$(animNum%)) THEN
  245.         IF animNum% = 0 THEN
  246.                 CreateIniKeyValue winDir$ + "win.ini","mci extensions", "mmm","animation", cmoOverwrite
  247.         ELSE
  248.                 CreateIniKeyValue winDir$ + "win.ini","mci extensions", "mmm","animation" + str$(animNum%), cmoOverwrite
  249.         END IF
  250.     END IF
  251.     ''IF needAnim$ = "yes" THEN
  252.         myDllYear% = 1991
  253.         myDllMonth% = 9
  254.         myDllDay% = 18
  255.         myDrvYear% = 1991
  256.         myDrvMonth% = 9
  257.         myDrvDay% = 19
  258.  
  259.         dllDate$ = getDateOfFile(sysDir$ + "mmp.dll")
  260.         drvDate$ = getDateOfFile(sysDir$ + "mcimmp.drv")
  261.         
  262.         dllYear% = getYearFromDate(dllDate$)
  263.         dllMonth% = getMonthFromDate(dllDate$)
  264.         dllDay% = getDayFromDate(dllDate$)
  265.         drvYear% = getYearFromDate(drvDate$)
  266.         drvMonth% = getMonthFromDate(drvDate$)
  267.         drvDay% = getDayFromDate(drvDate$)
  268.         
  269.         IF dllYear% < myDllYear% THEN
  270.             needDllUpdate$ = "yes"
  271.         ELSEIF dllYear% = myDllYear% THEN
  272.             IF dllMonth% < myDllMonth% THEN
  273.                  needDllUpdate$ = "yes"
  274.             ELSEIF dllMonth% = myDllMonth% THEN
  275.                 IF dllDay% < myDllDay% THEN
  276.                         needDllUpdate$ = "yes"
  277.                 END IF
  278.             END IF
  279.         END IF
  280.         IF needDllUpdate$ = "yes" THEN
  281.             IF f% = 1 THEN
  282.                  backupFile sysDir$ + "mmp.dll", "mmp.old"
  283.                  i% = DoMsgBox("Setup has found an older version of the Microsoft Movie Player DLL in your system. Updated and renamed your old file MMP.OLD", "SETUP", MB_TASKMODAL+MB_ICONEXCLAMATION+MB_OK)
  284.             END IF
  285.             copyFile srcDir$ + "mmp.dll", sysDir$ + "mmp.dll", cmoVital, 0
  286.             
  287.         END IF
  288.  
  289.         IF drvYear% < myDrvYear% THEN
  290.             needDrvUpdate$ = "yes"
  291.         ELSEIF drvYear% = myDrvYear% THEN
  292.             IF drvMonth% < myDrvMonth% THEN
  293.                  needDrvUpdate$ = "yes"
  294.             ELSEIF drvMonth% = myDrvMonth% THEN
  295.                 IF drvDay% < myDrvDay% THEN
  296.                         needDrvUpdate$ = "yes"
  297.                 END IF
  298.             END IF
  299.         END IF
  300.         IF needDrvUpdate$ = "yes" THEN
  301.             f% = DoesFileExist(sysDir$ + "mcimmp.drv",femExits)
  302.             IF f% = 1 THEN
  303.                  backupFile sysDir$ + "mcimmp.drv", "mcimmp.old"
  304.                  i% = DoMsgBox("Setup has found an older version of the Microsoft Movie driver in your system. Updated and renamed the old driver MCIMMP.OLD", "SETUP", MB_TASKMODAL+MB_ICONEXCLAMATION+MB_OK)
  305.             END IF
  306.             copyFile srcDir$ + "mcimmp.drv", sysDir$ + "mcimmp.drv", cmoVital, 0
  307.             
  308.         END IF
  309.     ''END IF
  310.  
  311.     AddSectionFilesToCopyList "Files", SrcDir$, DEST$
  312.     AddSectionKeyFileToCopyList "Options", OPTCUR$, SrcDir$, DEST$
  313.     CopyFilesInCopyList
  314.  
  315.     IF OPTCUR$ = "1" THEN
  316.         CreateProgmanGroup "Allie's Playhouse", "", cmoNone
  317.         ShowProgmanGroup "Allie's Playhouse", 1, cmoNone
  318.         CreateProgmanItem "Allie's Playhouse", "Allie's Playhouse", dest$ + "\tbook.exe " + dest$ + "\playhous.tbk", dest$ + "\playhous.ico", cmoOverwrite
  319.         CreateProgmanItem "Allie's Playhouse", "Uninstall", SrcDir$ + "tbook.exe " + dest$ + "\uninstal.tbk", dest$ + "\uninstal.ico", cmoOverwrite
  320.     ELSE
  321.         CreateProgmanGroup "Allie's Playhouse", "", cmoNone
  322.         ShowProgmanGroup "Allie's Playhouse", 1, cmoNone
  323.         CreateProgmanItem "Allie's Playhouse", "Allie's Playhouse", dest$ + "\tbook.exe " + srcDir$ + "playhous.tbk",dest$ + "\playhous.ico", cmoOverwrite
  324.         CreateProgmanItem "Allie's Playhouse", "uninstall", SrcDir$ + "tbook.exe " + dest$ + "\uninstal.tbk",dest$ + "\uninstal.ico", cmoOverwrite
  325.     END IF
  326.  
  327.     AddDos5Help "YOURAPP", "A brief help text for your Windows application."+chr$(10)+"It can be continued on another line with chr$(10).", cmoNone
  328.     IF needAnim$ = "yes" THEN
  329.         i% = DoMsgBox("A new animation driver has been installed in your system. Please restart Windows before starting Allie's Playhouse.", "SETUP", MB_TASKMODAL+MB_ICONEXCLAMATION+MB_OK)
  330.     END IF
  331.     CloseLogFile
  332.  
  333. END SUB
  334.  
  335.  
  336.  
  337. '**
  338. '** Purpose:
  339. '**     Appends a file name to the end of a directory path,
  340. '**     inserting a backslash character as needed.
  341. '** Arguments:
  342. '**     szDir$  - full directory path (with optional ending "\")
  343. '**     szFile$ - filename to append to directory
  344. '** Returns:
  345. '**     Resulting fully qualified path name.
  346. '*************************************************************************
  347. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  348.     IF szDir$ = "" THEN
  349.         MakePath = szFile$
  350.     ELSEIF szFile$ = "" THEN
  351.         MakePath = szDir$
  352.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  353.         MakePath = szDir$ + szFile$
  354.     ELSE
  355.         MakePath = szDir$ + "\" + szFile$
  356.     END IF
  357. END FUNCTION
  358.