home *** CD-ROM | disk | FTP | other *** search
/ Fun Online 1997 January / FOL0197.ISO / WING / WING.MST < prev    next >
Text File  |  1995-01-30  |  12KB  |  411 lines

  1. '**************************************************************************
  2. '*                       WinG Setup Program
  3. '**************************************************************************
  4.  
  5. '$DEFINE DEBUG  ''Define for script development/debugging
  6.  
  7. '$INCLUDE 'setupapi.inc'
  8.  
  9. ''Dialog ID's
  10. CONST WELCOME       = 100
  11. CONST ASKQUIT       = 200
  12. CONST DESTPATH      = 300
  13. CONST DESTPATH2     = 301
  14. CONST EXITFAILURE   = 400
  15. CONST EXITQUIT      = 600
  16. CONST EXITSUCCESS   = 700
  17. CONST APPHELP       = 900
  18. CONST CHECK         = 2500
  19. CONST BADPATH       = 6400
  20. CONST RESTART       = 1000
  21.  
  22. ''File Types
  23. CONST WING_RUNFILES     = 1
  24. CONST WING_BUILDFILES   = 2
  25.  
  26. ''Bitmap ID
  27. CONST LOGO = 1
  28.  
  29. GLOBAL FILEDIALOG   ''File path dialog ID
  30.  
  31. GLOBAL DEST$        ''Default destination directory.
  32.  
  33. GLOBAL CHECKSTATES$ ''Dialog list symbol names
  34. GLOBAL WINDRIVE$    ''Windows drive letter.
  35.  
  36. GLOBAL TMPDEST$        '' tmpfile destination
  37.  
  38. GLOBAL bInstallDVA%
  39.  
  40. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  41. DECLARE FUNCTION GetRealWindowsSysDir AS STRING
  42. DECLARE SUB UpdateWinG32 (szOrig$) 
  43.  
  44. DECLARE FUNCTION OnWin3x LIB "setuphlp.DLL" AS INTEGER
  45. DECLARE FUNCTION VflatdPresent LIB "setuphlp.DLL" AS INTEGER
  46. DECLARE FUNCTION GetRealSystemDir LIB "setuphlp.DLL" (szDir$,cbBuf%) AS INTEGER
  47. DECLARE FUNCTION RestartWindows LIB "setuphlp.DLL" AS INTEGER
  48. DECLARE FUNCTION IsWin32FileNewer LIB "setuphlp.DLL" (szOrig$,szNew$) AS INTEGER
  49. DECLARE SUB RenameFilePlease LIB "setuphlp.DLL" (szOrig$,szNew$) 
  50.  
  51. INIT:
  52.     bInstallDVA% = 0
  53.     
  54.     CUIDLL$ = "mscuistf.dll"            ''Custom user interface dll
  55.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  56.  
  57.     SetBitmap CUIDLL$, LOGO
  58.     SetTitle "Microsoft WinG Setup"
  59.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  60.     IF szInf$ = "" THEN
  61.     szInf$ = GetSymbolValue("STF_CWDDIR") + "wing.inf"
  62.     END IF
  63.     ReadInfFile szInf$
  64.  
  65. WELCOME:
  66.     sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$)
  67.     IF sz$ = "CONTINUE" THEN
  68.     UIPop 1
  69.     ELSE
  70.     GOSUB ASKQUIT
  71.     GOTO WELCOME
  72.     END IF
  73.  
  74.  
  75. ''    CHECKSTATES$ = "CheckItemsIn"
  76. ''    AddListItem CHECKSTATES$, "ON"    '' for run files
  77. ''    AddListItem CHECKSTATES$, "OFF"
  78. ''    AddListItem CHECKSTATES$, "OFF"     '' for development files
  79.  
  80. '' CHECK:
  81. ''    sz$ = UIStartDlg(CUIDLL$, CHECK, "FCheckDlgProc", APPHELP, HELPPROC$)
  82. ''    IF sz$ = "CONTINUE" THEN
  83. ''    UIPop 1
  84. ''    ELSE
  85. ''    GOSUB ASKQUIT
  86. ''    GOTO CHECK
  87. ''    END IF
  88.  
  89.     CHECKSTATES$ = "CheckItemsOut"
  90.     ''***************************************************
  91.     ''Reset the CheckItemsOut List for our own purposes
  92.     ''revised by Brian MacDonald
  93.     ''*******************************************************
  94.     SetSymbolValue CHECKSTATES$, "" 
  95.     AddListItem CHECKSTATES$, "ON" '' for run files
  96.     AddListItem CHECKSTATES$, "OFF" '' for development files
  97.     ''*********************************************************
  98.     
  99.     IF GetListItem(CHECKSTATES$, WING_RUNFILES) = "ON" THEN
  100.  
  101.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  102.     DEST$ = GetWindowsSysDir
  103.     
  104.     AddSectionFilesToCopyList "runtime", SrcDir$, DEST$
  105.     
  106.            '
  107.     ' only use DVA on Windows 3.x
  108.     '
  109.     IF OnWin3x() = 1 THEN
  110.         AddSectionFilesToCopyList "dva", SrcDir$, DEST$
  111.         IF VflatdPresent() = 0 THEN
  112.         CreateSysIniKeyValue GetWindowsDir + "system.ini", "386Enh", "device", GetWindowsSysDir+"dva.386", cmoOverwrite
  113.         bInstallDVA% = 1
  114.         END IF
  115.     END IF
  116.     
  117.     DEST$ = GetRealWindowsSysDir
  118.     
  119.     AddSectionFilesToCopyList "wing32", SrcDir$, DEST$
  120.            Dest1$ = MakePath(DEST$,"wing32.dll")
  121.            Dest2$ = MakePath(DEST$,"wing32.xxx")
  122.     RenameFilePlease Dest1$,Dest2$
  123.     
  124.     CopyFilesInCopyList
  125.     
  126.     UpdateWinG32 GetRealWindowsSysDir()
  127.  
  128.     END IF
  129.      
  130.     ''*****************************************************
  131.     ''We will not allow installing of development files
  132.     ''Revised by Brian MacDonald
  133.     ''*****************************************************
  134.     ReplaceListItem CHECKSTATES$, WING_BUILDFILES, "OFF"
  135.     ''******************************************************
  136.     
  137.     IF GetListItem(CHECKSTATES$, WING_BUILDFILES) = "ON" THEN
  138.     WINDRIVE$ = MID$(GetWindowsDir, 1, 1)
  139.     DEST$ = WINDRIVE$ + ":\WING"
  140.     FILEDIALOG = DESTPATH2
  141.     GOSUB GETPATH
  142.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  143.     CreateDir DEST$, cmoVital
  144.  
  145.     '' add devkit files to destination
  146.     
  147.     ' WinBug.exe taken out for first beta, maybe add it in later, and fix up .lyt file too!
  148.     'CreateDir MakePath(DEST$,"winbug"), cmoNone
  149.     'AddSectionFilesToCopyList "winbug", SrcDir$, MakePath(DEST$,"winbug")
  150.  
  151.     CreateDir MakePath(DEST$,"bin"), cmoNone
  152.     AddSectionFilesToCopyList "runtime", SrcDir$, MakePath(DEST$,"bin")
  153.     
  154.     AddSectionFilesToCopyList "wing32", SrcDir$, MakePath(DEST$,"bin")
  155.            Dest1$ = MakePath(DEST$,"bin\wing32.dll")
  156.            Dest2$ = MakePath(DEST$,"bin\wing32.xxx")
  157.     RenameFilePlease Dest1$,Dest2$
  158.     
  159.     AddSectionFilesToCopyList "bin", SrcDir$, MakePath(DEST$,"bin")
  160.     AddSectionFilestoCopyList "readme", SrcDir$, DEST$
  161.     CreateDir MakePath(DEST$,"include"), cmoNone
  162.     AddSectionFilesToCopyList "include", SrcDir$, MakePath(DEST$,"include")
  163.     CreateDir MakePath(DEST$,"help"), cmoNone
  164.     AddSectionFilesToCopyList "help", SrcDir$, MakePath(DEST$,"help")
  165.     CreateDir MakePath(DEST$,"lib"), cmoNone
  166.     AddSectionFilesToCopyList "lib", SrcDir$, MakePath(DEST$,"lib")
  167.     
  168.     GOSUB ADDSAMPLEFILESTOLIST
  169.     CopyFilesInCopyList
  170.     UpdateWinG32 MakePath( DEST$, "bin" )
  171.     GOSUB ADDGROUP
  172.     END IF
  173.  
  174. QUIT:
  175.     ON ERROR GOTO ERRQUIT
  176.  
  177.     IF ERR = 0 THEN
  178.     dlg% = EXITSUCCESS
  179.     ELSEIF ERR = STFQUIT THEN
  180.     dlg% = EXITQUIT
  181.     ELSE
  182.     dlg% = EXITFAILURE
  183.     END IF
  184.  
  185. QUITL1:
  186.     ''*********************************************
  187.     ''Don't require bInstallDVA = 1 to restart
  188.     ''Force the restart
  189.     ''revised by Brian MacDonald
  190.     ''**********************************************
  191.     ''if dlg% = EXITSUCCESS AND bInstallDVA% = 1 then 
  192.     if dlg% = EXITSUCCESS then
  193.     ''sz$ = UIStartDlg(CUIDLL$, RESTART, "FInfoDlgProc", APPHELP, HELPPROC$)
  194.     ''UIPop 1
  195.     ''IF sz$ = "CONTINUE" THEN
  196.     ''    rc% = RestartWindows
  197.     ''ENDIF
  198.         i% = DoMsgBox("Setup Succeeded.  You must now restart Windows.","Setup Succeeded -- Restart Windows",MB_OK)        
  199.         rc% = RestartWindows
  200.     endif
  201.  
  202.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  203.     IF sz$ = "REACTIVATE" THEN
  204.     GOTO QUITL1
  205.     END IF
  206.     UIPop 1
  207.     END
  208.  
  209. ERRQUIT:
  210.     i% = DoMsgBox("Setup sources were corrupted, call 555-1212!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  211.     END
  212.  
  213.  
  214. BADPATH:
  215.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  216.     IF sz$ = "REACTIVATE" THEN
  217.     GOTO BADPATH
  218.     END IF
  219.     UIPop 1
  220.     RETURN
  221.  
  222.  
  223. ASKQUIT:
  224.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  225.  
  226.     IF sz$ = "EXIT" THEN
  227.     UIPopAll
  228.     ERROR STFQUIT
  229.     ELSEIF sz$ = "REACTIVATE" THEN
  230.     GOTO ASKQUIT
  231.     ELSE
  232.     UIPop 1
  233.     END IF
  234.     RETURN
  235.  
  236.  
  237. GETPATH:
  238.     SetSymbolValue "EditTextIn", DEST$
  239.     SetSymbolValue "EditFocus", "END"
  240.  
  241. GETPATHL1:
  242.     sz$ = UIStartDlg(CUIDLL$, FILEDIALOG, "FEditDlgProc", APPHELP, HELPPROC$)
  243.     DEST$ = GetSymbolValue("EditTextOut")
  244.  
  245.     IF sz$ = "CONTINUE" THEN
  246.     IF IsDirWritable(DEST$) = 0 THEN
  247.         GOSUB BADPATH
  248.         GOTO GETPATHL1
  249.     END IF
  250.     UIPop 1
  251.     ELSEIF sz$ = "REACTIVATE" THEN
  252.     GOTO GETPATHL1
  253.     ELSEIF sz$ = "BACK" THEN
  254.     UIPop 1 
  255.     '' GOTO CHECK
  256.     ''***********************************************
  257.     ''Go to Welcome instead of Check
  258.     '' revised by Brian MacDonald
  259.     ''************************************************* 
  260.     GOTO WELCOME
  261.     ''***********************************************
  262.     ELSE
  263.     GOSUB ASKQUIT
  264.     GOTO GETPATH
  265.     END IF
  266.  
  267.     RETURN
  268.  
  269. ADDSAMPLEFILESTOLIST:
  270.     SamplePath$ = MakePath(DEST$,"samples")
  271.     CreateDir SamplePath$, cmoNone
  272.  
  273. '       Add doggie example program
  274.  
  275.     sample$ = "doggie"
  276.  
  277.     CreateDir MakePath(SamplePath$,sample$), cmoNone
  278.     AddSectionFilesToCopyList sample$, SrcDir$, MakePath(SamplePath$,sample$)
  279.  
  280. '       Add cube example program
  281.  
  282.     sample$ = "cube"
  283.  
  284.     CreateDir MakePath(SamplePath$,sample$), cmoNone
  285.     AddSectionFilesToCopyList sample$, SrcDir$, MakePath(SamplePath$,sample$)
  286.  
  287. '       Add utils example code
  288.  
  289.     sample$ = "utils"
  290.  
  291.     CreateDir MakePath(SamplePath$,sample$), cmoNone
  292.     AddSectionFilesToCopyList sample$, SrcDir$, MakePath(SamplePath$,sample$)
  293.  
  294. '       Add timewing example program
  295.  
  296.     sample$ = "timewing"
  297.  
  298.     CreateDir MakePath(SamplePath$,sample$), cmoNone
  299.     AddSectionFilesToCopyList sample$, SrcDir$, MakePath(SamplePath$,sample$)
  300.  
  301. '       Add halftone example program
  302.  
  303.     sample$ = "halftone"
  304.  
  305.     CreateDir MakePath(SamplePath$,sample$), cmoNone
  306.     AddSectionFilesToCopyList sample$, SrcDir$, MakePath(SamplePath$,sample$)
  307.  
  308. '       Add palanim example program
  309.  
  310.     sample$ = "palanim"
  311.  
  312.     CreateDir MakePath(SamplePath$,sample$), cmoNone
  313.     AddSectionFilesToCopyList sample$, SrcDir$, MakePath(SamplePath$,sample$)
  314.  
  315. '       Other sample programs go here
  316.  
  317.     RETURN
  318.     
  319. ADDGROUP:
  320.     SamplePath$ = MakePath(DEST$,"samples")
  321.     proggroup$ = "WinG SDK"
  322.     CreateProgmanGroup proggroup$, "", cmoNone
  323.     
  324.         path$ = MakePath( DEST$, "help\wing.hlp" )
  325.     CreateProgmanItem proggroup$, "WinG Help", "winhelp "+path$, "", cmoOverwrite
  326.     
  327.         path$ = MakePath( DEST$, "bin\wingbug.exe" )
  328.     CreateProgmanItem proggroup$, "WinG Bug Reporting Tool", path$, "", cmoOverwrite
  329.     
  330.     path$ = MakePath( SamplePath$,"doggie\doggie.exe")
  331.     CreateProgmanItem proggroup$, "Doggie", path$, "", cmoOverwrite
  332.     
  333.     path$ = MakePath( SamplePath$,"cube\cube.exe")
  334.     CreateProgmanItem proggroup$, "Cube",path$,"", cmoOverwrite
  335.     
  336.     path$ = MakePath( SamplePath$,"timewing\timewing.exe")
  337.     CreateProgmanItem proggroup$, "Time WinG",path$,"", cmoOverwrite
  338.     
  339.     path$ = MakePath( SamplePath$,"halftone\halftone.exe")
  340.     CreateProgmanItem proggroup$, "Halftone",path$,"", cmoOverwrite
  341.     
  342.     path$ = MakePath( SamplePath$,"palanim\palanim.exe")
  343.     CreateProgmanItem proggroup$, "Palette Animation",path$,"", cmoOverwrite
  344.     
  345. '       Other sample programs get added here
  346.     
  347.     RETURN
  348.  
  349. '**
  350. '** Purpose:
  351. '**     Appends a file name to the end of a directory path,
  352. '**     inserting a backslash character as needed.
  353. '** Arguments:
  354. '**     szDir$  - full directory path (with optional ending "\")
  355. '**     szFile$ - filename to append to directory
  356. '** Returns:
  357. '**     Resulting fully qualified path name.
  358. '*************************************************************************
  359. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  360.     IF szDir$ = "" THEN
  361.     MakePath = szFile$
  362.     ELSEIF szFile$ = "" THEN
  363.     MakePath = szDir$
  364.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  365.     MakePath = szDir$ + szFile$
  366.     ELSE
  367.     MakePath = szDir$ + "\" + szFile$
  368.     END IF
  369. END FUNCTION
  370.  
  371.  
  372. FUNCTION GetRealWindowsSysDir STATIC AS STRING
  373.     szBuf$ = string$(260, 32)
  374.     cbBuf% = GetRealSystemDir(szBuf$, 260)
  375.     IF cbBuf% = 0 THEN
  376.         ERROR STFERR
  377.     ELSE
  378.         IF cbBuf% > 259 THEN
  379.             res% = DoMsgBox("Buffer Overflow", "MS-Setup Error", MB_ICONHAND+MB_OK)
  380.             ERROR STFERR
  381.         END IF
  382.         szBuf$ = RTRIM$(szBuf$)
  383.         IF MID$(szBuf$, 1, 1) = "\" THEN
  384.             szBuf$ = MID$(CURDIR$, 1, 2) + szBuf$
  385.         ELSEIF MID$(szBuf$, 2, 1) <> ":" THEN
  386.             szBuf$ = MID$(CURDIR$, 1, 3) + szBuf$
  387.         END IF
  388.         IF MID$(szBuf$, LEN(szBuf$), 1) <> "\" THEN
  389.             szBuf$ = szBuf$ + "\"
  390.         END IF
  391.         GetRealWindowsSysDir = szBuf$
  392.     END IF
  393.  
  394.     szBuf$ = ""
  395. END FUNCTION
  396.  
  397. SUB UpdateWinG32 (szOrig$) STATIC 
  398.     '
  399.     ' Here we check the version ourselves of wing32.dll, since 
  400.     ' we can't get version checking for Win32 apps from Win16
  401.     '
  402.     FileNew$ = MakePath(szOrig$, "wing32.dll")
  403.     FileOrig$ = MakePath(szOrig$, "wing32.xxx")
  404.     IF IsWin32FileNewer( FileOrig$, FileNew$ ) THEN
  405.     RemoveFile FileOrig$, cmoForce
  406.     ELSE
  407.         RemoveFile FileNew$, cmoForce        ' get rid of new file
  408.     RenameFilePlease FileOrig$,FileNew$    ' put back old file
  409.     END IF
  410. END SUB
  411.