home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / gkdemo.zip / WIN32S.EXE / 32SINST.MST < prev    next >
Text File  |  1994-12-23  |  12KB  |  427 lines

  1. ' THIS DOES NOT INSTALL FREECELL
  2. '' $DEFINE DEBUG  ''Define for script development/debugging
  3.  
  4. '$INCLUDE 'setupapi.inc'
  5. '$INCLUDE 'msdetect.inc'
  6.  
  7. ''Dialog ID's
  8. CONST WELCOME       = 100
  9. CONST ASKQUIT       = 200
  10. CONST DESTPATH      = 300
  11. CONST EXITFAILURE   = 400
  12. CONST EXITQUIT      = 600
  13. CONST EXITSUCCESS   = 700
  14. CONST OPTIONS       = 800
  15. CONST BADPATH       = 6400
  16.  
  17. CONST HELPWELCOME   = 1000
  18. CONST VERPATH       = 1100
  19. CONST EXITFAILNOTWIN31 = 1200
  20. CONST EXITFAILNOTENH = 1300
  21. CONST EXITFAILNOTPAGING = 1325
  22. CONST EXITFAILNOTINTEL = 1350
  23. CONST FREECELLINST  = 1400
  24. CONST FREECELLINSTNOWIN32S = 1450
  25. CONST FREECELLPATH  = 1500
  26. CONST HELPFREECELL  = 1600
  27.  
  28.  
  29. ''Bitmap ID
  30. CONST LOGO = 1
  31.  
  32. GLOBAL DESTSYS$      ''Windows\System directory.
  33. GLOBAL DEST32S$      ''Windows\System\Win32s directory
  34. GLOBAL DESTFREE$     ''Freecell directory
  35.  
  36. DECLARE SUB Install
  37. DECLARE SUB UpdateSystemIni
  38. DECLARE SUB RebootSystem
  39. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  40. DECLARE FUNCTION MakeSystemIni LIB "INIUPD.DLL" (arg1$, arg2$) AS INTEGER
  41. DECLARE FUNCTION RestartWindows LIB "INIUPD.DLL" AS INTEGER
  42. DECLARE FUNCTION OnWindowsNT LIB "INIUPD.DLL" AS INTEGER
  43. DECLARE FUNCTION PagingEnabled LIB "INIUPD.DLL" AS INTEGER
  44. DECLARE FUNCTION ShareEnabled LIB "INIUPD.DLL" AS INTEGER
  45. DECLARE FUNCTION IsWin32sLoaded LIB "INIUPD.DLL" (arg1$) AS INTEGER
  46. DECLARE FUNCTION ExitWindowsExec LIB "USER.EXE" (arg1$, arg2$) AS INTEGER
  47.  
  48. INIT:
  49.     CUIDLL$ = "mscuistf.dll"            ''Custom user interface dll
  50.     HELPPROC$ = "FHelpDlgProc"      ''Help dialog procedure
  51.     szOldVer$ ="1.00.000     "      ''Reserve space in string for version
  52.     WIN32ENABLED% = 0
  53.     GLOBAL AlwaysCopy%
  54.     AlwaysCopy% = 0
  55.     ON ERROR GOTO ERRNORMAL
  56.  
  57.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  58.  
  59.     SetBitmap CUIDLL$, LOGO
  60.     SetTitle "Microsoft Win32s Setup Program"
  61.  
  62.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  63.     IF szInf$ = "" THEN
  64.     szInf$ = GetSymbolValue("STF_CWDDIR") + "32sinst.inf"
  65.     END IF
  66.     ReadInfFile szInf$
  67.  
  68.     DESTSYS$ = GetWindowsSysDir()
  69.     DEST32S$ = DESTSYS + "WIN32S\"
  70.  
  71. '$IFDEF DEBUG
  72.     i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
  73.     WinDrive$ = MID$(GetWindowsDir, 1, 1)
  74.     IF IsDriveValid(WinDrive$) = 0 THEN
  75.     i% = DoMsgBox("Windows drive ('"+WinDrive$+"') is not a valid drive.", "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
  76.     GOTO QUIT
  77.     END IF
  78. '$ENDIF ''DEBUG
  79.  
  80. CHECK:
  81.     IF GetWindowsMajorVersion < 3 THEN
  82.     ExitCode% = EXITFAILNOTWIN31
  83.     GOTO QUIT
  84.     END IF
  85.     IF GetWindowsMajorVersion = 3 AND GetWindowsMinorVersion < 1 THEN
  86.     ExitCode% = EXITFAILNOTWIN31
  87.     GOTO QUIT
  88.     END IF
  89.     IF GetWindowsMajorVersion >= 4 THEN
  90.     ExitCode% = EXITSUCCESS
  91.     WIN32ENABLED% = 1
  92.     GOTO FREECELL
  93.     END IF
  94.     IF GetWindowsMode < 2  THEN
  95.     IF OnWindowsNT() THEN
  96.        ExitCode% = EXITFAILNOTINTEL '' Running on Windows NT (on RISC)
  97.     ELSE
  98.        ExitCode% = EXITFAILNOTENH   '' Standard Mode Windows
  99.     END IF
  100.     GOTO QUIT
  101.     END IF
  102.     IF OnWindowsNT() THEN
  103.     ExitCode% = EXITSUCCESS
  104.     WIN32ENABLED% = 1
  105.     GOTO FREECELL
  106.     END IF
  107.     ExitCode% = EXITSUCCESS
  108.  
  109.     '' Get version of Win32s to be installed from version info in file
  110.     szNewVer$ = GetVersionOfFile( GetSymbolValue("STF_SRCDIR") + "WIN32S16.DLL" )
  111.  
  112.     '' Check if Win32s is partially installed
  113.     sz$ = GetIniKeyString (DESTSYS$ + "WIN32S.INI", "Win32s", "Setup")
  114.     '' If WIN32S.INI specifies Setup=0, then force complete Win32s file overwrite
  115.     IF sz$ = "0" THEN
  116.     AlwaysCopy% = 1
  117.     GOTO WELCOME
  118.     END IF
  119.     '' If WIN32S.INI is missing, try and reinstall Win32s files/recreate WIN32S.INI
  120.     IF sz$ <> "1" THEN
  121.     GOTO WELCOME
  122.     END IF
  123.  
  124.     '' If Win32s is already installed, get running version number
  125.     i% = DoesFileExist( DESTSYS$ + "W32SYS.DLL", femExists )
  126.     IF i% = 1 THEN
  127.     i% = IsWin32sLoaded( szOldVer$ )
  128.     ENDIF
  129.  
  130.     IF i% = 0 THEN
  131.     GOTO WELCOME
  132.     END IF
  133.     IF szNewVer$ > szOldVer$ THEN
  134.     GOTO WELCOME
  135.     END IF
  136.     WIN32ENABLED% = 1
  137.     GOTO FREECELL
  138.  
  139. WELCOME:
  140.     sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", HELPWELCOME, HELPPROC$)
  141.     IF sz$ = "CONTINUE" THEN
  142.     UIPop 1
  143.     ELSE
  144.     GOSUB ASKQUIT
  145.     GOTO WELCOME
  146.     END IF
  147.  
  148.  
  149. GETWIN32SPATH:
  150.     IF PagingEnabled() = 0 THEN
  151.     i% = DoMsgBox("Use the Control Panel 386 Enhanced icon and configure Windows using the Virtual Memory option.", "Win32s requires Virtual Memory", MB_TASKMODAL+MB_ICONHAND+MB_OK)
  152.     ExitCode% = EXITFAILURE '' Enhanced mode but not paging
  153.     GOTO QUIT
  154.     END IF
  155.  
  156.     IF ShareEnabled() = 0 THEN
  157.     i% = DoMsgBox( "File-sharing must be enabled. Run SHARE.EXE before starting Windows or add SHARE.EXE to your AUTOEXEC.BAT file.", "Win32s Setup: SHARE.EXE is not loaded", MB_TASKMODAL+MB_ICONEXCLAMATION+MB_OK)
  158.     END IF
  159.  
  160.     SetSymbolValue "EditTextIn", DESTSYS$
  161.     SetSymbolValue "EditFocus", "END"
  162.  
  163. GETPATHL1:
  164.     sz$ = UIStartDlg(CUIDLL$, VERPATH, "FDispDlgProc", HELPWELCOME, HELPPROC$)
  165.  
  166.     IF sz$ = "CONTINUE" THEN
  167.     IF IsDirWritable(DESTSYS$) = 0 THEN
  168.         GOSUB BADPATH
  169.         GOTO GETPATHL1
  170.     END IF
  171.     UIPop 1
  172.     ELSEIF sz$ = "REACTIVATE" THEN
  173.     GOTO GETPATHL1
  174.     ELSEIF sz$ = "BACK" THEN
  175.     UIPop 1
  176.     GOTO WELCOME
  177.     ELSE
  178.     GOSUB ASKQUIT
  179.     GOTO GETPATHL1
  180.     END IF
  181.  
  182. COPYFILES:
  183.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Setup", "0", cmoOverwrite
  184.  
  185.     '' Indicate Win32s install failure until all files known to be copied.
  186.     ExitCode% = EXITFAILURE
  187.     ERR = 0
  188.     CreateDir DEST32S$, cmoNone
  189.     Install
  190.     UpdateSystemIni
  191.     '' Terminate if unhandled fatal error
  192.     IF ERR <> 0 THEN
  193.     GOTO QUIT
  194.     END IF
  195.  
  196.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Setup", "1", cmoOverwrite
  197.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Version", szNewVer$, cmoOverwrite
  198.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Nls", "AnsiCP", "1252", cmoOverwrite
  199.  
  200.     i% = DoMsgBox("Win32s files successfully installed.", "Microsoft Win32s Setup", MB_OK+MB_TASKMODAL)
  201.     '' Indicate Win32s correctly copied and installed.
  202.     ExitCode% = EXITSUCCESS
  203.  
  204. FREECELL:
  205.     goto QUIT ' Remove to install freecell
  206.     IF WIN32ENABLED% = 1 THEN
  207.     sz$ = UIStartDlg(CUIDLL$, FREECELLINSTNOWIN32S, "FInfoDlgProc",0, "")
  208.     ELSE
  209.     sz$ = UIStartDlg(CUIDLL$, FREECELLINST, "FInfoDlgProc",0, "")
  210.     END IF
  211.     IF sz$ = "CONTINUE" THEN
  212.     UIPop 1
  213.     ELSE
  214.     GOTO QUIT
  215.     END IF
  216.  
  217. GETFREEPATH:
  218.     DESTFREE$ = MID$(DESTSYS$,1,3) + "WIN32APP\FREECELL\"
  219.     SetSymbolValue "EditTextIn", DESTFREE$
  220.     SetSymbolValue "EditFocus", "END"
  221.  
  222. GETFREEPATHL1:
  223.     sz$ = UIStartDlg(CUIDLL$, FREECELLPATH, "FEditDlgProc", HELPFREECELL, HELPPROC$)
  224.  
  225.     IF sz$ = "CONTINUE" THEN
  226.     DESTFREE$ = GetSymbolValue("EditTextOut")
  227.  
  228.     IF MID$(DESTFREE$, LEN(DESTFREE$), 1) <> "\" THEN
  229.         DESTFREE$ = DESTFREE$ + "\"
  230.     END IF
  231.     ''Validate new path.
  232.     IF IsDirWritable(DESTFREE$) = 0 THEN
  233.         GOSUB BADPATH
  234.         GOTO GETFREEPATHL1
  235.     END IF
  236.     UIPop 1
  237.  
  238.     GOTO COPYFREECELL
  239.     ELSEIF sz$ = "REACTIVATE" THEN
  240.     GOTO GETFREEPATHL1
  241.     ELSEIF sz$ = "EXIT" THEN
  242.     UIPop 1
  243.     GOTO QUIT
  244.     END IF
  245.  
  246. COPYFREECELL:
  247.     ClearCopyList
  248.     CreateDir DESTFREE$, cmoNone
  249.  
  250.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  251.  
  252.     ERR = 0
  253.     AddSectionFilesToCopyList "Win32appFreecell", SrcDir$, DESTFREE$
  254.     CopyFilesInCopyList
  255.     '' If error copying FreeCell, not a fatal error. Win32s is already installed.
  256.     IF ERR <> 0 THEN
  257.     ERR = 0
  258.     GOTO QUIT
  259.     END IF
  260.     ERR = 0
  261.  
  262.     IF DoesFileExist( DESTSYS$ + "WIN32S.INI", femExists ) THEN
  263.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Freecell", "Setup", "1", cmoOverwrite
  264.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Freecell", "Version", szNewVer$, cmoOverwrite
  265.     END IF
  266.  
  267.     ERR = 0
  268.     CreateProgmanGroup "Win32 Applications", "", cmoNone
  269.     ShowProgmanGroup   "Win32 Applications", 1, cmoNone
  270.     CreateProgmanItem  "Win32 Applications", "Freecell", DESTFREE$ + "FREECELL.EXE", "", cmoOverwrite
  271.     '' Only put up success dialog if icon added to group
  272.     IF ERR = 0 THEN
  273.     i% = DoMsgBox("Freecell was successfully installed.", "Freecell Setup", MB_OK+MB_TASKMODAL)
  274.     END IF
  275.     ERR = 0
  276.  
  277. QUIT:
  278.     '' Install error handler for final message box routines
  279.     ON ERROR GOTO ERRQUIT
  280.     IF ERR = 0 THEN
  281.     dlg% = ExitCode%
  282.     ELSEIF ERR = STFQUIT THEN
  283.     dlg% = EXITQUIT
  284.     ExitCode% = EXITQUIT
  285.     ELSE
  286.     dlg% = EXITFAILURE
  287.     ExitCode% = EXITQUIT
  288.     END IF
  289.  
  290. QUITL1:
  291.     IF WIN32ENABLED% = 1 THEN
  292.     UIPop 1
  293.     END
  294.     END IF
  295.  
  296.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  297.     IF sz$ = "REACTIVATE" THEN
  298.     GOTO QUITL1
  299.     END IF
  300.     UIPop 1
  301.  
  302.     IF ExitCode% = EXITSUCCESS THEN
  303.     RebootSystem
  304.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Setup", "0", cmoOverwrite
  305.     i% = DoMsgBox("Win32s is not properly configured and Win32s Setup must be run again.", "Unable to Restart Windows", MB_ICONEXCLAMATION+MB_OK+MB_TASKMODAL)
  306.     ENDIF
  307.  
  308.     END
  309.  
  310. '' Fatal error handler for error message routine
  311. ERRQUIT:
  312.     i% = DoMsgBox("Setup sources were corrupted!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  313.     END
  314.  
  315. '' Bypass run-time errors. Let final dialog box display fatal error message.
  316. ERRNORMAL:
  317.     '' Check if user cancelled setup
  318.     IF ERR = STFQUIT THEN
  319.     GOTO QUIT
  320.     END IF
  321.     RESUME NEXT
  322.  
  323.  
  324. BADPATH:
  325.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  326.     IF sz$ = "REACTIVATE" THEN
  327.     GOTO BADPATH
  328.     END IF
  329.     UIPop 1
  330.     RETURN
  331.  
  332.   ASKQUIT:
  333.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  334.  
  335.     IF sz$ = "EXIT" THEN
  336.     UIPopAll
  337.     ERROR STFQUIT
  338.     ELSEIF sz$ = "REACTIVATE" THEN
  339.     GOTO ASKQUIT
  340.     ELSE
  341.     UIPop 1
  342.     END IF
  343.     RETURN
  344.  
  345.  
  346.  
  347. '**
  348. '** Purpose:
  349. '**     Builds the copy list and performs all installation operations.
  350. '** Arguments:
  351. '**     none.
  352. '** Returns:
  353. '**     none.
  354. '*************************************************************************
  355. SUB Install STATIC
  356.  
  357.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  358.  
  359.     '' Check if overwrite required.
  360.     IF AlwaysCopy% = 1 THEN
  361.     '' Use file layout sections that specify ALWAYS overwrite files
  362.     AddSectionFilesToCopyList "_WindowsSystem", SrcDir$, DESTSYS$
  363.     AddSectionFilesToCopyList "_WindowsSystemWin32s", SrcDir$, DESTSYS$ + "WIN32S\"
  364.     ELSE
  365.     '' Use file layout sections that specify OLDER file version/time check
  366.     AddSectionFilesToCopyList "WindowsSystem", SrcDir$, DESTSYS$
  367.     AddSectionFilesToCopyList "WindowsSystemWin32s", SrcDir$, DESTSYS$ + "WIN32S\"
  368.     END IF
  369.     SetRestartDir GetWindowsDir()
  370.  
  371.     CopyFilesInCopyList
  372.  
  373. END SUB
  374.  
  375. SUB UpdateSystemIni STATIC
  376.  
  377.     VxDPath$ = DEST32S$ + "W32S.386"
  378.     SystemIniPath$ = GetWindowsDir()
  379.  
  380.     t% = MakeSystemIni(SystemIniPath$, VxdPath$)
  381.  
  382. END SUB
  383.  
  384. SUB RebootSystem STATIC
  385.  
  386. '   Check if any files were locked during install.  If the RestartList
  387. '   is not empty, ExitExecRestart() will restart Windows, cleanup setup
  388. '   files, and copy over locked files before Windows restarts.
  389.     i% = RestartListEmpty()
  390.     IF i% = 0 THEN
  391. '      ExitExecRestart() only returns if applications refuse to be shutdown.
  392. '      Win32s is installed but will not operate until Windows is restarted
  393. '      and the Win32s VxD is loaded.
  394.        i% = ExitExecRestart()
  395.      ELSE
  396. '      If the RestartList list is empty, it is necessary to restart windows
  397. '      directly.  The MSSETUP program creates _MSRSTRT.EXE and _MSSETUP.BAT
  398. '      in the restart directory.  This program should be exec'd to handle
  399. '      proper MSSETUP cleanup (temp files) and restart Windows.
  400.        i% = ExitWindowsExec( GetWindowsDir() + "_MSRSTRT.EXE", "_MSSETUP.BAT" )
  401.      ENDIF
  402.  
  403. END SUB
  404.  
  405.  
  406. '**
  407. '** Purpose:
  408. '**     Appends a file name to the end of a directory path,
  409. '**     inserting a backslash character as needed.
  410. '** Arguments:
  411. '**     szDir$  - full directory path (with optional ending "\")
  412. '**     szFile$ - filename to append to directory
  413. '** Returns:
  414. '**     Resulting fully qualified path name.
  415. '*************************************************************************
  416. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  417.     IF szDir$ = "" THEN
  418.     MakePath = szFile$
  419.     ELSEIF szFile$ = "" THEN
  420.     MakePath = szDir$
  421.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  422.     MakePath = szDir$ + szFile$
  423.     ELSE
  424.     MakePath = szDir$ + "\" + szFile$
  425.     END IF
  426. END FUNCTION
  427.