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