home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer 8 / 1995-07_Disc_8.iso / shgmdemo / install / inst.mst < prev    next >
Text File  |  1995-03-08  |  47KB  |  1,389 lines

  1. '**************************************************************************
  2. '*  MS Test script for Win32s, WinG, and Shanghai Great Moments
  3. '**************************************************************************
  4.  
  5. ''$DEFINE DEBUG  ''Define for script development/debugging
  6.  
  7. ''XXX
  8. ''$define   MYDEBUG '' define for script development'
  9.  
  10. '$INCLUDE 'setupapi.inc'
  11. '$INCLUDE 'msdetect.inc'
  12.  
  13. '*-------------------------------[ Constants ]------------------------------*'
  14. const MIN_DRIVE_SPACE           = 12000000  '' 12 megs
  15. const LOGO                      = 1         ''Bitmap ID
  16. const InfFile$                  = "shgm.inf"   '
  17. const ErrStr$                   = "**** ERROR ****: "
  18. const CUIDLL$                   = "mscuistf.dll"
  19.  
  20. const hlpOFFSET                 = 10    '' add to dialog ID to get help dlg ID
  21.  
  22. const verNOT_EXIST              = 0
  23. const verIS_OLDER               = 1
  24. const verINCOMPLETE             = 2
  25. const verSAME_BUT_MISSING       = 3
  26. const verSAME_AND_VALID         = 4
  27. const verIS_NEWER               = 5
  28.  
  29.  
  30. '*-------------------------------[ Dialog IDs ]-----------------------------*'
  31.  
  32. const dlgWELCOME                = 100   '' Welcome dialog box
  33. const hlpWELCOME                = 110   '' Help msgbox for welcome dialog
  34.  
  35. const dlgASKQUIT                = 200   '' Confirm quit install dialog
  36.  
  37. ''Finished! dialog boxes
  38. ''
  39. const EXITSUCCESS               = 700   '' Successful install msgbox
  40. const   dlgOK_NEED_W32S_WING    = 710   '' Install ok, but still need WinG/W32s
  41. const   dlgOK_NEED_W32S         = 720   '' Install ok, but still need W32s
  42. const   dlgOK_NEED_WING         = 730   '' Install ok, but still need WinG
  43.  
  44. '' Final dialog boxes
  45. ''
  46. const dlgRESTART_MUST           = 740
  47. const dlgRESTART_PLEASE         = 750
  48.  
  49. const dlgBADDISKSPACE           = 10000 '' insufficient space on disk
  50. const dlgBADDISKSPACEEXT        = 10010 '' insufficient space on disk for
  51.                                         '' extensions
  52. const dlgBADPATH                = 10100 '' bad path msgbox
  53. const dlgBADDRIVE               = 10110 '' bad drive msgbox
  54.  
  55. '' Status dialog boxes
  56. const dlgSCANW32S               = 300   '' Checking for Win32s files
  57. const dlgSCANWING               = 301   '' Checking for WinG files
  58. const dlgCHECKSPACE             = 350   '' Checking disk space
  59.  
  60.  
  61. '' Notify install/skip-install dialogs
  62. ''
  63. const dlgW32S                   = 5000
  64. const dlgWING                   = 5100
  65. const dlgSHGM                   = 5200  '' this one asks for destination path
  66.  
  67. const dlgNO_SHARE               = 1330  ''
  68. const hlpNO_SHARE               = 1010  '' Help msgbox for no-share warning
  69.  
  70. '' Confirmation dialog boxes
  71. ''
  72. const dlgCONFIRM_OVER_W32S      = 2000
  73. const dlgCONFIRM_OVER_WING      = 2010
  74.  
  75. const dlgCONFIRM_SKIP_W32S      = 2100
  76. const dlgCONFIRM_SKIP_WING      = 2110
  77.  
  78.  
  79. '' Install failure codes that also correspond to dialog msgbox id numbers
  80. ''
  81. const exitFAILURE               = 400   '' generic Failure msgbox
  82. const exitFAILW32S              = 410   '' Win32s install failure
  83. const exitFAILWING              = 420   '' WinG install failure
  84. const exitFAILSHGM              = 430   '' SHGM install failure
  85. const exitQUIT                  = 600   '' User quit install msgbox
  86.  
  87. '' System config errors that cause install failure
  88. ''
  89. const sysfailNOTWIN31           = 1200  ''
  90. const sysfailNOTENH             = 1300  '' Not enhanced mode Win3.1x failure
  91. const sysfailNOTPAGING          = 1325  '' No VM enabled failure
  92. const sysfailNOTINTEL           = 1350
  93. const sysFAILRUNAPP             = 1360  '' Win32s failure (Win32s active)
  94. const sysfailNT31               = 1365  '' version of NT was less than 3.5
  95. const sysfail256COLOR           = 1370  '' 256 color mode not detected
  96.  
  97. const verSKU$                   = "SKU" '' Main SKU
  98. const verPOP$                   = "POP" '' POP demo
  99. const verCVR$                   = "CVR" '' Cover demo
  100.  
  101. '*------------------------------[ Misc Globals ]----------------------------*'
  102. global driveWinSys$         '' Drive Windows is on
  103. global dirWinSys$           '' Windows\System directory.
  104. global dirWinSysWin32s$     '' Windows\System\Win32s directory
  105. global dirSHGM$             '' SHGM destination directory
  106. global SrcDir$              '' Source directory (where the .INF file is)
  107.  
  108. '' status flags
  109. global onWin31%             '' 0 = not 3.1x, 1 = on Win3.1x
  110. global win32Enabled%        '' 0 = not enabled, 1 = enabled
  111. global prevW32s%            '' set to one of the ver?????? constants
  112. global prevWinG%            '' set to one of the ver?????? constants
  113.  
  114. global szW32OldVer$
  115.  
  116. global boolLog%             '' 0 = logfile closed, 1 = logfile open
  117.  
  118. global instVers$
  119.  
  120. '*-------------------------------[ Prototypes ]-----------------------------*'
  121. declare sub InstallWin32sFiles
  122. declare sub InstallWinGFiles
  123. declare sub InstallSHGMFiles
  124.  
  125. declare function RebootSystem AS INTEGER
  126. declare function MakePath (szDir$, szFile$) AS STRING
  127.  
  128. declare sub dputs(arg1$)    '' print string to logfile or debug screen with '\n'
  129.  
  130. declare sub W32SAddToCopyList
  131. declare sub WINGAddToCopyList
  132. declare sub SHGMAddToCopyList
  133.  
  134. declare function InstallVFlatD as integer
  135.  
  136. declare function DoesSectionFilesExist(szSection$,szDirPath$,dlgID%) as integer
  137.  
  138. declare function Have256Colors as integer
  139.  
  140. declare function ConfirmDialog(dlgID%) as integer
  141.  
  142. '*-------------------------[ External DLL functions ]-----------------------*'
  143. '$ifdef MYDEBUG
  144. declare function OutputDebugString LIB "KRNL386.EXE" (arg1$) as integer
  145. '$endif
  146.  
  147. declare function OnWindowsNT LIB "INIUPD.DLL" AS INTEGER
  148. declare function PagingEnabled LIB "INIUPD.DLL" AS INTEGER
  149. declare function ShareEnabled LIB "INIUPD.DLL" AS INTEGER
  150. declare function IsWin32sLoaded LIB "INIUPD.DLL" (arg1$) AS INTEGER
  151. declare function IsRunningApp LIB "INIUPD.DLL" AS INTEGER
  152.  
  153. declare function SetCuiFlags LIB "MSCUISTF.DLL" (arg1%, arg2%) AS INTEGER
  154.  
  155. declare function ExitWindowsExec LIB "USER.EXE" (arg1$, arg2$) AS INTEGER
  156.  
  157. '' WinG stuff
  158. declare function VflatdPresent LIB "setuphlp.DLL" AS INTEGER
  159. declare function RestartWindows LIB "setuphlp.DLL" AS INTEGER
  160. ''declare function OnWin3x LIB "setuphlp.DLL" AS INTEGER
  161. ''declare function GetRealSystemDir LIB "setuphlp.DLL" (szDir$,cbBuf%) AS INTEGER
  162. ''declare function IsWin32FileNewer LIB "setuphlp.DLL" (szOrig$,szNew$) AS INTEGER
  163. ''declare sub RenameFilePlease LIB "setuphlp.DLL" (szOrig$,szNew$)
  164.  
  165.  
  166. '' Custom stuff in UTILS.DLL to update SYSTEM.INI
  167. declare function UpdateIniW32S LIB "utils.dll" as integer
  168. declare function UpdateIniWING LIB "utils.dll" as integer
  169.  
  170. '*----------------------------[ Start of script ]---------------------------*'
  171. INIT:
  172.     HELPPROC$     = "FHelpDlgProc"      '' Help dialog procedure
  173.     szW32OldVer$  = "1.00.000     "     '' Reserve space in string for version
  174.  
  175.     '' bools
  176.     onWin31%      = 0
  177.     win32Enabled% = 0
  178.  
  179.     '' flags to indicate existence or previous versions
  180.     prevW32s%     = ver_NOT_EXIST
  181.     prevWinG%     = ver_NOT_EXIST
  182.  
  183.     okW32S%       = 0
  184.     okWING%       = 0
  185.     okSHGM%       = 0
  186.  
  187.     instW32S%     = 0
  188.     instWING%     = 0
  189.     instSHGM%     = 0
  190.  
  191.     doAddDVA%     = 0
  192.  
  193.     warnNeedW32S% = 0
  194.     warnNeedWING% = 0
  195.  
  196.     systemIniBackedUp% = 0
  197.  
  198.     ON ERROR goto ERRNORMAL
  199.  
  200.     '' Read in the .INF file
  201.     ''
  202.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  203.  
  204.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  205.     if szInf$ = "" then
  206.         szInf$ = GetSymbolValue("STF_CWDDIR") + InfFile$
  207.     endif
  208.     ReadInfFile szInf$
  209.  
  210.     '' Setup a pretty looking screen :)
  211.     ''
  212.     SetBitmap CUIDLL$, LOGO
  213.     SetTitle "Shanghai: Great Moments Setup"
  214.  
  215.     '' Determine install type
  216.     instVers$ = GetSymbolValue("VER_INSTALL")
  217.  
  218.     '' Determine install directories
  219.     ''
  220.     dirWinSys$ = GetWindowsSysDir()
  221.     dirWinSysWin32s$ = dirWinSys$ + "WIN32S\"
  222.     driveWinSys$ = MID$(GetWindowsDir, 1, 1)
  223.  
  224.     driveNeeds$ = "DriveNeeds"
  225.  
  226. '$IFDEF DEBUG
  227.     i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
  228.     driveWinSys$ = MID$(GetWindowsDir, 1, 1)
  229.     if IsDriveValid(driveWinSys$) = 0 then
  230.         i% = DoMsgBox("Windows drive ('"+driveWinSys$+"') is not a valid drive.", "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
  231.         goto Quit
  232.     endif
  233. '$ENDIF ''DEBUG
  234.  
  235.     ExitCode% = EXITSUCCESS
  236.  
  237. '*-------------------------[ Check Min Requirements ]-----------------------*'
  238.     '' Can not run on versions less than 3.10.
  239.     dputs("---- Checking Windows version")
  240.     if GetWindowsMajorVersion < 3 then
  241.         dputs(ErrStr$ + "Windows version less than 3.1")
  242.         ExitCode% = sysfailNOTWIN31
  243.         goto Quit
  244.     endif
  245.  
  246.     if GetWindowsMajorVersion = 3 AND GetWindowsMinorVersion < 10 then
  247.         dputs(ErrStr$ + "Windows version less than 3.1")
  248.         ExitCode% = sysfailNOTWIN31
  249.         goto Quit
  250.     endif
  251.  
  252.     '' Make sure we're not in standard mode, nor are we on a RISC system
  253.     if GetWindowsMode < 2  then
  254.         if OnWindowsNT() then
  255.             dputs(ErrStr$ + "RISC computer running Windows NT (only Intel supported)")
  256.             ExitCode% = sysfailNOTINTEL '' Running on Windows NT (on RISC)
  257.         else
  258.             dputs(ErrStr$ + "Standard mode Windows detected")
  259.             ExitCode% = sysfailNOTENH   '' Standard Mode Windows
  260.         endif
  261.         goto Quit
  262.     endif
  263.  
  264.     '' Make sure display is configured for 256 color mode
  265.     if Have256Colors = 0 then
  266.         dputs("Display not configured for 256 color mode")
  267.         ExitCode% = sysfail256COLOR
  268.         goto Quit
  269.     else
  270.         dputs("Display configured for 256 color mode")
  271.     endif
  272.  
  273.  
  274. '*-------------------------[ Get program directory ]------------------------*'
  275. PromptInstall:
  276.     i% = SetCuiFlags(0,0)
  277.     sz$ = UIStartDlg(CUIDLL$, dlgWELCOME, "FInfoDlgProc", hlpWELCOME, HELPPROC$)
  278.     if sz$ = "CONTINUE" then
  279.         UIPop 1
  280.     else
  281.         gosub AskQuit
  282.         goto PromptInstall
  283.     endif
  284.  
  285.     '' Determine available drives
  286.     driveList$ = "DrivesList"
  287.     GetLocalHardDrivesList(driveList$)
  288.  
  289. GetSHGMDest:
  290.     numDrives% = GetListLength(driveList$)
  291.     dirSHGM$ = ""
  292.     if (numDrives% <> 0) then
  293.         for i%= 1 to numDrives% step 1
  294.             sz$ = GetListItem(driveList$,i%)
  295.             avail& = GetFreeSpaceForDrive(sz$)
  296.             if avail& >= MIN_DRIVE_SPACE then
  297.                 dirSHGM$ = sz$ + ":\SHGM\"
  298.                 exit for
  299.             endif
  300.         next i%
  301.     endif
  302.  
  303.     if dirSHGM$ = "" then
  304.         dirSHGM$ = driveWinSys$ + ":\SHGM\"
  305.     endif
  306.  
  307.     SetSymbolValue "EditTextIn", dirSHGM$
  308.     SetSymbolValue "EditFocus", "END"
  309. GetSHGMDest1:
  310.     sz$ = UIStartDlg(CUIDLL$, dlgSHGM, "FEditDlgProc", dlgSHGM + hlpOFFSET, HELPPROC$)
  311.     if sz$ = "CONTINUE" then
  312.         dirSHGM$ = GetSymbolValue("EditTextOut")
  313.         dirSHGM$ = LTRIM$(RTRIM$(dirSHGM$))
  314.          
  315.         '' Validate new drive
  316.         w$ = MID$(dirSHGM$,1,1)
  317.         if IsDriveValid(w$) = 0 then
  318.             gosub BadDrive
  319.             goto GetSHGMDest1
  320.         endif
  321.         
  322.         ''Validate new path.
  323.         if IsDirWritable(dirSHGM$) = 0 then
  324.             gosub BadPath
  325.             goto GetSHGMDest1
  326.         endif
  327.  
  328.  
  329.         '' Make sure drive has sufficient free space
  330.         '' Making sure we take into account an already existent
  331.         '' SH3.DS file
  332.         ''
  333.         i% = GetDrive
  334.         needed& = MIN_DRIVE_SPACE
  335.         szDS$ = MakePath(MakePath(dirSHGM$,"DATA"),"SH3.DS")
  336.         if DoesFileExist(szDS$,femExists) = 1 then
  337.             if GetSizeOfFile(szDS$) > needed& then
  338.                 '' EEK!
  339.                 gosub BadDriveSpace
  340.                 goto GetSHGMDest1
  341.             else
  342.                 needed& = needed& - GetSizeOfFile(szDS$)
  343.             endif
  344.         endif
  345.         szDS$ = ""
  346.  
  347.         if GetFreeSpaceForDrive(w$) < needed& then
  348.             gosub BadDriveSpace
  349.             goto GetSHGMDest1
  350.         endif
  351.         
  352.         UIPop 1
  353.     elseif sz$ = "REACTIVATE" then
  354.         goto GetSHGMDest1
  355.     else
  356.         gosub AskQuit
  357.         goto GetSHGMDest
  358.     endif
  359.  
  360.  
  361.     '' Create the directory if possible
  362.     ExitCode% = exitFAILSHGM
  363.  
  364. ''XXX
  365. ''    sz$ = MakePath(dirSHGM$,"SHGM")
  366. ''    if DoesDirExist(sz$) = 0 then
  367.     if DoesDirExist(dirSHGM$) = 0 then
  368.         CreateDir dirSHGM$, cmoNone
  369.     endif
  370.     '' Terminate if unhandled fatal error
  371.     if ERR <> 0 then
  372.         goto Quit
  373.     endif
  374.  
  375.     '' Open logfile
  376.     OpenLogFile MakePath(dirSHGM$,"SHGM.LOG"), 0
  377.     boolLog% = 1
  378.     '' Terminate if unhandled fatal error
  379.     if ERR <> 0 then
  380.         goto Quit
  381.     endif
  382.  
  383.     if DoesDirExist(MakePath(dirSHGM$,"DATA")) = 0 then
  384.         CreateDir MakePath(dirSHGM$,"DATA"), cmoNone
  385.     endif
  386.     SetRestartDir GetWindowsDir()
  387.     '' Terminate if unhandled fatal error
  388.     if ERR <> 0 then
  389.         goto Quit
  390.     endif
  391.  
  392.     ExitCode% = EXITSUCCESS
  393.  
  394. '*-------------------------[ Check if Win32s needed ]-----------------------*'
  395.     if OnWindowsNT() then
  396.         dputs("    Windows NT detected")
  397.         if GetWindowsMajorVersion * 100 + GetWindowsMinorVersion < 350 then
  398.             dputs(ErrStr$ + "Windows NT version was less than 3.5")
  399.             ExitCode% = sysfailNT31
  400.             goto Quit
  401.         else
  402.             dputs("    Version of WinNT is at least 3.5")
  403.             dputs("    Win32s install is NOT required")
  404.             ExitCode% = EXITSUCCESS
  405.             win32Enabled% = 1
  406.             okW32S% = 1
  407.             goto CheckForWinG
  408.         endif
  409.     endif
  410.  
  411.     '' Check that we are not running on Chicago, including pre-released
  412.     '' Chicago versions.
  413.     if GetWindowsMajorVersion * 100 + GetWindowsMinorVersion > 350 then
  414.         dputs("    Pre-release Chicago or Win95 detected")
  415.         dputs("    Win32s install is NOT required")
  416.         ExitCode% = EXITSUCCESS
  417.         win32Enabled% = 1
  418.         okW32S% = 1
  419.         goto CheckForWinG
  420.     endif
  421.  
  422. '*----------------------------[ Check for Win32s ]--------------------------*'
  423.     '' We're on Win3.1x or WFW3.1x
  424.     ''
  425.     onWin31% = 1
  426.     dputs("    Windows 3.1x detected")
  427.  
  428.     '' Make sure paging has been enabled
  429.     if PagingEnabled() = 0 then
  430.         dputs(ErrStr$ + "Virtual memory (paging) is not enabled")
  431.         ExitCode% = sysfailNOTPAGING   '' Enhanced mode but not paging
  432.         goto Quit
  433.     endif
  434.  
  435.     '' Make sure share has been enabled
  436.     '' Failure to have SHARE enabled is not fatal, we just inform the
  437.     '' user that he/she should setup Windows to have SHARE enabled
  438.     ''
  439.     if ShareEnabled() = 0 then
  440. PromptNoShare:
  441.         sz$ = UIStartDlg(CUIDLL$, dlgNO_SHARE, "FInfoDlgProc", hlpNO_SHARE, HELPPROC$)
  442.         UIPop 1
  443.         if sz$ = "REACTIVATE" then
  444.             goto PromptNoShare
  445.         elseif sz$ <> "CONTINUE" then
  446.             ExitCode% = exitQUIT
  447.             goto Quit
  448.         endif
  449.     endif
  450.  
  451.     '' Get version of Win32s to be installed from version info in .INF file
  452.     szW32NewVer$ = GetSectionKeyVersion("WindowsSystem", "win32s16.dll")
  453.  
  454.     dputs("---- Checking Win32s presence")
  455.  
  456.     '' Check if Win32s is partially installed by determining if
  457.     '' WIN32S.INI file exists
  458.     dputs("    Checking for existence of file WIN32S.INI")
  459.     if DoesIniKeyExist(dirWinSys$ + "WIN32S.INI", "Win32s", "Setup") = 0 then
  460.         dputs("    WIN32S.INI file was NOT found")
  461.         prevW32s% = verNOT_EXIST    '' no WIN32S.INI file found (no Win32s found)
  462.         goto Win32sCheckDone
  463.     endif
  464.     dputs("    WIN32S.INI file was found")
  465.  
  466.     ''
  467.     sz$ = GetIniKeyString (dirWinSys$ + "WIN32S.INI", "Win32s", "Setup")
  468.  
  469.     '' If Setup key in WIN32S.INI is not valid then suggest re-install
  470.     ''
  471.     if sz$ <> "1" then
  472.         dputs("    [Setup] section in WIN32S.INI describes previous install failure")
  473.         prevW32s% = verINCOMPLETE   '' Previously incomplete install detected
  474.         goto Win32sCheckDone
  475.     endif
  476.  
  477.     '' If Win32s is already installed, get running version number
  478.     ''
  479.     i% = DoesFileExist( dirWinSys$ + "W32SYS.DLL", femExists )
  480.     if i% <> 1 then
  481.         prevW32s% = verINCOMLPETE   '' no W32SYS.DLL found (no Win32s found)
  482.         goto Win32sCheckDone
  483.     endif
  484.  
  485.     i% = IsWin32sLoaded(szW32OldVer$)
  486.     if i% = 0 then
  487.         prevW32s% = verINCOMPLETE   '' Previously incomplete install detected
  488.         goto Win32sCheckDone
  489.     endif
  490.  
  491.     dputs("    Current installed version of Win32s is " + szW32OldVer$)
  492.  
  493.     '' If older Win32s, then tell user that we would like to overwrite
  494.     if szW32NewVer$ > szW32OldVer$ then
  495.         prevW32s% = verIS_OLDER     '' Old version found
  496.         goto Win32sCheckDone
  497.     endif
  498.  
  499.     '' Newer or equal version detected on system
  500.     if szW32NewVer$ = szW32OldVer$ then
  501.         dputs("    Identical version of Win32s files detected")
  502.         dputs("")
  503.         dputs("--- Now checking to make sure that all required Win32s")
  504.         dputs("    files are present on the system")
  505.         dputs("")
  506.  
  507.         if DoesSectionFilesExist("WindowsSystemWin32s",dirWinSysWin32s$,dlgSCANW32S) <> 1 then
  508.             dputs("    Since one or more Win32s files are missing,")
  509.             dputs("    a Win32s re-install is recommended")
  510.             dputs("")
  511.             prevW32s% = verSAME_BUT_MISSING '' Same version detected,
  512.             goto Win32sCheckDone
  513.         elseif DoesSectionFilesExist("WindowsSystem",dirWinSys$,dlgSCANW32S) <> 1 then
  514.             dputs("    Since one or more Win32s files are missing,")
  515.             dputs("    a Win32s re-install is recommended")
  516.             dputs("")
  517.             prevW32s% = verSAME_BUT_MISSING '' Same version detected,
  518.             goto Win32sCheckDone
  519.         endif
  520.  
  521.         prevW32s% = verSAME_AND_VALID   '' Valid Win32s already present
  522.         okW32S% = 1
  523.     else
  524.         prevW32s% = verIS_NEWER '' Newer Win32s detected
  525.         okW32S% = 1
  526.     endif
  527.  
  528.     win32Enabled% = 1           '' say Win32s already enabled
  529.     goto Win32sCheckDone
  530.  
  531. Win32sCheckDone:
  532.  
  533. '*------------------[ Confirm Win32s Install/Skip-install ]-----------------*'
  534.     dlg% = prevW32s% + dlgW32S
  535.     dlgHelp% = dlg% + hlpOFFSET
  536.  
  537.     if prevW32s% = verNOT_EXIST then
  538.         dputs("Win32s was not detected: install of Win32s suggested")
  539.     elseif prevW32s% = verINCOMPLETE then
  540.         dputs("Win32s install suggested: previous install was incomplete")
  541.     elseif prevW32s% = verIS_OLDER then
  542.         dputs("Win32s install suggested: older version detected")
  543.     elseif prevW32s% = verSAME_BUT_MISSING then
  544.         dputs("Win32s install suggested: One or more Win32s files were missing")
  545.     elseif prevW32s% = verSAME_AND_VALID then
  546.         dputs("Win32s install NOT suggested: A valid Win32s exists")
  547.     elseif prevW32s% = verIS_NEWER then
  548.         dputs("Win32s install NOT suggested: A newer Win32s exists")
  549.     else
  550.         dputs("Internal error")
  551.         error STFERR
  552.     endif
  553.  
  554. PromptNotifyWin32sInstall:
  555.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfoDlgProc", dlgHelp%, HELPPROC$)
  556.     if (sz$ = "EXIT") or (sz$ = "CANCEL") then
  557.         gosub AskQuit
  558.         goto PromptNotifyWin32sInstall
  559.     elseif sz$ = "REACTIVATE" then
  560.         goto PromptNotifyWIn32sInstall
  561.     elseif sz$ = "CONTINUE" then
  562.         '' User chose CONTINUE or INSTALL
  563.         UIPop 1
  564.         if (prevW32s% = verSAME_AND_VALID) or (prevW32s% = verIS_NEWER) then
  565.             '' Button was CONTINUE
  566.             goto CheckForWinG
  567.         else
  568.             '' Button was INSTALL
  569.             goto DoW32sInstall
  570.         endif
  571.     else
  572.         '' User chose SKIP, or OVERWRITE
  573.         if (prevW32s% = verSAME_AND_VALID) or (prevW32s% = verIS_NEWER) then
  574.             '' Button was OVERWRITE
  575.             if (ConfirmDialog(dlgCONFIRM_OVER_W32S) = 1) then
  576.                 UIPop 1
  577.                 dputs("*** Though Win32s install is not recommended,")
  578.                 dputs("    User has chosen to overwrite existing Win32s files")
  579.                 goto DoW32sInstall
  580.             else
  581.                 ''UIPop 1
  582.                 goto PromptNotifyWin32sInstall
  583.             endif
  584.         else
  585.             '' Button was SKIP
  586.             if (ConfirmDialog(dlgCONFIRM_SKIP_W32S) = 1) then
  587.                 dputs("*** Though Win32s install is suggested,")
  588.                 dputs("    User has chosen not to (re)install Win32s")
  589.                 warnNeedW32s% = 1   '' warn user later
  590.                 UIPop 1
  591.                 goto CheckForWinG
  592.             else
  593.                 ''UIPop 1
  594.                 goto PromptNotifyWin32sInstall
  595.             endif
  596.         endif
  597.         UIPop 1
  598.     endif
  599.  
  600. DoW32SInstall:
  601.     '' Make sure Win32s has not already been installed and
  602.     '' currently providing services for a Win32s application
  603.     if (IsRunningApp() <> 0) then
  604.         dputs("Win32s can not be (re)installed: A Win32 application is running")
  605.         ExitCode% = sysFAILRUNAPP
  606.         goto Quit
  607.     endif
  608.  
  609.     '' Add Win32s files to copy list
  610.     dputs("---- User chose to install Win32s, adding Win32s files to global copy list")
  611.     instW32S% = 1
  612.     W32SAddToCopyList
  613.  
  614. '*----------------------[ Check if WinG install needed ]--------------------*'
  615. CheckForWinG:
  616.     dputs("---- Checking for WinG presence")
  617.  
  618.     dputs("    Checking for existence of file WING.DLL in Windows System directory")
  619.     if DoesFileExist(dirWinSys$ + "wing.dll", femExists) <> 1 then
  620.         dputs("    WING.DLL not found (WinG not install), WinG install suggested")
  621.         prevWinG% = verNOT_EXIST    '' no WinG detected
  622.         goto WinGCheckDone
  623.     endif
  624.  
  625.     szNewVer$ = GetSectionKeyVersion("WinG", "wing.dll")
  626.     szCurrVer$ = GetVersionOfFile(dirWinSys$ + "wing.dll")
  627.  
  628.     dputs("    WinG found on system")
  629.     dputs("    Supplied version is: " + szNewVer$)
  630.     dputs("    Current version is:  " + szCurrVer$)
  631.     if (szNewVer$ > szCurrVer$) then
  632.         dputs("    Older version of WinG was found, WinG re-install recommended")
  633.         prevWinG% = verIS_OLDER
  634.     elseif (szNewVer$ < szCurrVer$) then
  635.         dputs("    Newer version of WinG was found, WinG install is NOT suggested")
  636.         prevWinG% = verIS_NEWER '' newer version found
  637.     elseif (szNewVer$ = szCurrVer$) then
  638.         dputs("    Same version detected")
  639.         dputs("")
  640.         dputs("--- Now checking to make sure that all required WinG")
  641.         dputs("    files are present on the system")
  642.         dputs("")
  643.         if DoesSectionFilesExist("WinG",dirWinSys$,dlgSCANWING) <> 1 then
  644.             dputs("    Since one or more WinG files are missing,")
  645.             dputs("    a WinG re-install is recommended")
  646.             dputs("")
  647.             prevWinG% = verSAME_BUT_MISSING '' Some files are missing
  648.         else
  649.             dputs("    WinG configuration seems valid, WinG install is NOT suggested")
  650.             prevWinG% = verSAME_AND_VALID   '' version is equivalent and files exist
  651.         endif
  652.     endif
  653.  
  654. WinGCheckDone:
  655.     if (prevWinG% = verSAME_AND_VALID) then
  656.         dputs("Newer version of WinG found, WinG install NOT suggested")
  657.     elseif (prevWinG% = verIS_NEWER) then
  658.         dputs("Valid version of WinG found, WinG install NOT suggested")
  659.     else
  660.         dputs("WinG installation suggested")
  661.     endif
  662.  
  663.     dlg% = prevWinG% + dlgWING
  664.     dlgHelp% = dlg% + hlpOFFSET
  665.     if prevWinG% = verNOT_EXIST then
  666.         dputs("WinG was not detected: install of WinG suggested")
  667.     elseif prevWinG% = verIS_OLDER then
  668.         dputs("WinG install suggested: older version detected")
  669.     elseif prevWinG% = verSAME_BUT_MISSING then
  670.         dputs("WinG install suggested: One or more WinG files were missing")
  671.     elseif prevWinG% = verSAME_AND_VALID then
  672.         dputs("WinG install NOT suggested: A valid WinG exists")
  673.     elseif prevWinG% = verIS_NEWER then
  674.         dputs("WinG install NOT suggested: A newer WinG exists")
  675.     else
  676.         '' Internal error
  677.         dputs("**** Internal error ****")
  678.     endif
  679.  
  680. PromptWinGInstall:
  681.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfoDlgProc", dlgHelp%, HELPPROC$)
  682.     if (sz$ = "EXIT") or (sz$ = "CANCEL") then
  683.         gosub AskQuit
  684.         goto PromptWinGInstall
  685.     elseif sz$ = "REACTIVATE" then
  686.         goto PromptWinGInstall
  687.     elseif sz$ = "CONTINUE" then
  688.         '' User chose CONTINUE or INSTALL
  689.         UIPop 1
  690.         if (prevWinG% = verSAME_AND_VALID) or (prevWinG% = verIS_NEWER) then
  691.             '' Button was CONTINUE
  692.             goto CheckWinDriveCosts
  693.         else
  694.             '' Button was INSTALL
  695.             goto DoWinGInstall
  696.         endif
  697.     else
  698.         '' User chose SKIP, or OVERWRITE
  699.         if (prevWinG% = verSAME_AND_VALID) or (prevWinG% = verIS_NEWER) then
  700.             '' Button was OVERWRITE
  701.             if (ConfirmDialog(dlgCONFIRM_OVER_WING) = 1) then
  702.                 UIPop 1
  703.                 dputs("*** Though WinG install is not recommended,")
  704.                 dputs("    User has chosen to overwrite existing WinG files")
  705.                 goto DoWinGInstall
  706.             else
  707.                 ''UIPop 1
  708.                 goto PromptWinGInstall
  709.             endif
  710.         else
  711.             '' Button was SKIP
  712.             if (ConfirmDialog(dlgCONFIRM_SKIP_WING) = 1) then
  713.                 dputs("*** Though WinG install is suggested,")
  714.                 dputs("    User has chosen not to (re)install WinG")
  715.                 warnNeedWING% = 1
  716.                 UIPop 1
  717.                 goto CheckWinDriveCosts
  718.             else
  719.                 ''UIPop 1
  720.                 goto PromptWinGInstall
  721.             endif
  722.         endif
  723.         UIPop 1
  724.     endif
  725.  
  726. DoWinGInstall:
  727.     '' XXX If possible, make sure WinG is not currently running and providing
  728.     '' services to an application
  729.  
  730.     '' Add WinG files to copy list
  731.     dputs("---- User chose to install WinG, adding WinG files to global copy list")
  732.     instWING% = 1
  733.     WINGAddToCopyList
  734.  
  735. '*-------------------[ Check cost of installing W32s/WinG ]-----------------*'
  736.  
  737. CheckWinDriveCosts:
  738.     CursorSave% = ShowWaitCursor()
  739. CWDC:
  740.     sz$ = UIStartDlg(CUIDLL$,dlgCHECKSPACE,"FModelessDlgProc", 0, "")
  741.     if sz$ = "REACTIVATE" then
  742.         goto CWDC
  743.     endif
  744.  
  745.     dputs("---- Determining disk space needs")
  746.     i% = GetCopyListCost("",driveNeeds$,"")
  747.     lenList% = GetListLength(driveNeeds$)
  748.     for i% = 1 to 26 step 1
  749.         cost& = val(GetListItem(driveNeeds$,i%))
  750.         if (cost& <> 0) then
  751.             '' Determine drive
  752.             w$ = chr$(i% + asc("A") - 1)
  753.             if GetFreeSpaceForDrive(w$) < cost& then
  754.                 '' Insufficient disk space to update Windows
  755.                 UIPop 1
  756.                 RestoreCursor CursorSave%
  757.                 ExitCode% = dlgBADDISKSPACEEXT
  758.                 goto Quit
  759.             endif
  760.         endif
  761.     next i%
  762.  
  763.     UIPop 1
  764.     RestoreCursor CursorSave%
  765.     ClearCopyList
  766.  
  767.  
  768. '*-------------------------[ Perform Win32s Install ]-----------------------*'
  769.     if instW32S% = 0 then
  770.         goto InstallWinG
  771.     endif
  772.  
  773.     dputs("---- Now installing Win32s")
  774.  
  775.     '' Indicate Win32s install failure until all files known to be copied.
  776.     ''
  777.     if DoesIniKeyExist(dirWinSys$ + "WIN32S.INI", "Win32s", "Setup") = 0 then
  778.         CreateIniKeyValue dirWinSys$ + "WIN32S.INI", "Win32s", "Setup", "0", cmoOverwrite
  779.     endif
  780.  
  781.     ExitCode% = exitFAILW32S
  782.     ERR = 0
  783.     CreateDir dirWinSysWin32s$, cmoNone
  784.     InstallWin32sFiles
  785.  
  786. ''XXX will ERR always be 0 on success? (even if files could not be
  787. ''copied and had to be put into the restart list?)
  788. ''
  789.     '' Terminate if unhandled fatal error
  790.     if ERR <> 0 then
  791.         goto Quit
  792.     endif
  793.  
  794.     '' Make backup of SYSTEM.INI
  795.     '' Add/Update "device=W32S.386" to SYSTEM.INI under [386Enh]
  796.     '' Add/Update "drivers=mmsystem.dll winmm16.dll" to SYSTEM.INI under [boot]
  797.     ''
  798.     if (systemIniBackedUp% = 0) then
  799.         dputs("Creating backup of SYSTEM.INI")
  800.         dputs("  backup name: " + MakePath(dirSHGM$,"SYSTEM.SGM"))
  801.         CopyFile MakePath(GetWindowsDir,"SYSTEM.INI"),MakePath(dirSHGM$,"SYSTEM.SGM"),cmoForce,0
  802.         systemIniBackedUp% = 1
  803.     endif
  804.     '' Terminate if unhandled fatal error
  805.     if ERR <> 0 then
  806.         goto Quit
  807.     endif
  808.  
  809.  
  810.     dputs("Updating SYSTEM.INI file:")
  811.     dputs("  adding device=W32SYS.386 statement to SYSTEM.INI")
  812.     t% = UpdateIniW32S()
  813.     if t% = 0 then
  814.         dputs(ErrStr$ + "Win32s install failure: Unable to Update SYSTEM.INI")
  815.         goto Quit
  816.     endif
  817.  
  818.     '' Terminate if unhandled fatal error
  819.     if ERR <> 0 then
  820.         goto Quit
  821.     endif
  822.  
  823.  
  824.     '' Update WIN32S.INI file
  825.     ''
  826.     dputs("Updating WIN32S.INI")
  827.     CreateIniKeyValue dirWinSys$ + "WIN32S.INI", "Win32s", "Setup", "1", cmoOverwrite
  828.     CreateIniKeyValue dirWinSys$ + "WIN32S.INI", "Win32s", "Version", szW32NewVer$, cmoOverwrite
  829.     CreateIniKeyValue dirWinSys$ + "WIN32S.INI", "Nls", "AnsiCP", "1252", cmoOverwrite
  830.  
  831.     '' Indicate Win32s correctly copied and installed.
  832.     ExitCode% = EXITSUCCESS
  833.  
  834. '*---------------------------[ Install WinG files ]-------------------------*'
  835. InstallWinG:
  836.     if instWING% = 0 then
  837.         goto InstallSHGM
  838.     endif
  839.  
  840.     dputs("---- Installing WinG files")
  841.     ExitCode% = exitFAILWING
  842.     ERR = 0
  843.     InstallWinGFiles
  844.  
  845.     '' Terminate if unhandled fatal error
  846.     if ERR <> 0 then
  847.         goto QUIT
  848.     endif
  849.  
  850.     '' Backup SYSTEM.INI if we haven't already done so
  851.     '' Make sure DVA.386 is setup correctly in SYSTEM.INI
  852.     if InstallVFlatD <> 0 then
  853.         if (systemIniBackedUp% = 0) then
  854.             dputs("Creating backup of SYSTEM.INI")
  855.             dputs("  backup name: " + MakePath(dirSHGM$,"SYSTEM.SGM"))
  856.             CopyFile MakePath(GetWindowsDir,"SYSTEM.INI"),MakePath(dirSHGM$,"SYSTEM.SGM"),cmoForce,0
  857.             systemIniBackedUp% = 1
  858.         endif
  859.         dputs("Updating SYSTEM.INI file:")
  860.         dputs("  Adding device=DVA.386 statement to SYSTEM.INI")
  861.         t% = UpdateIniWING()
  862.         if t% = 0 then
  863.             dputs(ErrStr$ + "WinG install failure: Unable to update SYSTEM.INI")
  864.             goto Quit
  865.         endif
  866.     endif
  867.  
  868.     '' Terminate if unhandled fatal error
  869.     if ERR <> 0 then
  870.         goto QUIT
  871.     endif
  872.  
  873.     '' Indicate WinG correctly copied and installed.
  874.     ExitCode% = EXITSUCCESS
  875.  
  876.  
  877. '*------------------------------[ Install SHGM ]----------------------------*'
  878. InstallSHGM:
  879.     dputs("---- Installing SHGM files")
  880.     ExitCode% = exitFAILWING
  881.     ERR = 0
  882.     InstallSHGMFiles
  883.     '' Terminate if unhandled fatal error
  884.     if ERR <> 0 then
  885.         goto QUIT
  886.     endif
  887.  
  888.     '' Have shell program (Program Manager) associate .SHV files with
  889.     '' SHGM.EXE if it doesn't already do it
  890.     ''
  891.     if DoesIniKeyExist("WIN.INI", "Extensions", "SHV") = 0 then
  892.         dputs("Creating backup of WIN.INI")
  893.         CopyFile MakePath(GetWindowsDir,"WIN.INI"),MakePath(dirSHGM$,"WIN.SGM"),cmoForce,0
  894.         dputs("  backup name: " + MakePath(dirSHGM$,"WIN.SGM"))
  895.         dputs("  Adding .SHV extension association to [Extensions]")
  896.  
  897.         dputs("  section of WIN.INI file")
  898.         CreateIniKeyValue "WIN.INI", "Extensions", "SHV", "shgm.exe ^.SHV", cmoNone
  899.     endif
  900.  
  901.     '' Create program group and items
  902.     ''
  903.     if (instVers$ = verSKU$) then
  904.         CreateProgmanGroup "Activision", "", cmoNone
  905.         ShowProgmanGroup  "Activision", 1, cmoNone
  906.         CreateProgmanItem "Activision", "Shanghai: Great Moments", MakePath(dirSHGM$,"shgm.exe"), "", cmoOverwrite
  907.     elseif (instVers$ = verPOP$) then
  908.         CreateProgmanGroup "Activision", "", cmoNone
  909.         ShowProgmanGroup  "Activision", 1, cmoNone
  910.         CreateProgmanItem "Activision", "Shanghai: GM Demo", MakePath(dirSHGM$,"shgm.exe"), "", cmoOverwrite
  911.     else '' instVers$ = verCVR$
  912.         CreateProgmanGroup "Activision", "", cmoNone
  913.         ShowProgmanGroup  "Activision", 1, cmoNone
  914.         CreateProgmanItem "Activision", "Shanghai: GM Demo", MakePath(dirSHGM$,"shgm.exe"), "", cmoOverwrite
  915.     endif
  916.     CreateProgmanItem "Activision", "Shanghai Rules", MakePath(dirSHGM$,"shgm.hlp"), "", cmoOverwrite
  917.     CreateProgmanItem "Activision", "Shanghai Troubleshooting", MakePath(dirSHGM$,"techhelp.wri"), "", cmoOverwrite
  918.  
  919.     '' Indicate SHGM correctly copied and installed.
  920.     ''
  921.     ExitCode% = EXITSUCCESS
  922.  
  923. '*--------------------------[ End install process ]-------------------------*'
  924. QUIT:
  925.     '' Install error handler for final message box routines
  926.     err% = ERR
  927.     ON ERROR goto ERRQUIT
  928.     if err% = 0 then
  929.         dlg% = ExitCode%        '' exit dialog based on ExitCode
  930.     elseif err% = STFQUIT then
  931.         dlg% = exitQUIT
  932.         ExitCode% = exitQUIT    '' user chose to quit install failure
  933.     else
  934.         dlg% = exitFAILURE      '' non-specific install failure
  935.         ExitCode% = exitQUIT
  936.     endif
  937.  
  938.     '' If install was successful, then say so
  939.     '' Note: if user chose not to (re)install either Win32s or WinG
  940.     '' then inform user that the game will not function correctly
  941.     '' until Win32s and WinG are present
  942.     ''
  943.     if dlg% = EXITSUCCESS then
  944.         if (warnNeedWING% <> 0) and (warnNeedW32S% <> 0) then
  945.             dlg% = dlgOK_NEED_W32S_WING
  946.         elseif (warnNeedWING% <> 0) then
  947.             dlg% = dlgOK_NEED_WING
  948.         elseif (warnNeedW32S% <> 0) then
  949.             dlg% = dlgOK_NEED_W32S
  950.         endif
  951.     endif
  952.  
  953. QUITL1:
  954.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  955.     if sz$ = "REACTIVATE" then
  956.         goto QUITL1
  957.     endif
  958.     UIPop 1
  959.  
  960.  
  961.     if ExitCode% <> EXITSUCCESS then
  962.         dputs(ErrStr$ + "Install failure")
  963.         CloseLogFile
  964.         boolLog% = 0
  965.         end '' End script!
  966.     endif
  967.  
  968.  
  969. '*-----------------------[ Install Ok, Attempt Reboot ]---------------------*'
  970.     if RestartListEmpty = 0 then
  971.         dputs("--- Restart list is not empty (files were locked)")
  972.         dputs("    Windows MUST be restarted to complete file installation")
  973.         dlg% = dlgRESTART_MUST
  974.     else
  975.         dputs("--- Restart list is empty ")
  976.         dputs("    Windows restart is suggested")
  977.         dlg% = dlgRESTART_PLEASE
  978.     endif
  979.  
  980.  
  981. AskReboot:
  982.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfoDlgProc", 0, "")
  983.     if sz$ = "REACTIVATE" then
  984.         goto AskReboot
  985.     endif
  986.     UIPop 1
  987.  
  988.     '' return code is alwyas "CONTINUE" unless dialog box
  989.     '' alloed an "EXIT" button
  990.     ''
  991.     if sz$ <> "CONTINUE" then
  992.         dputs("--- User chose not to restart Windows")
  993.         CloseLogFile
  994.         boolLog% = 0
  995.         end '' END SCRIPT!
  996.     endif
  997.  
  998.  
  999.     dputs("--- Attempting to restart Windows")
  1000.  
  1001.     CloseLogFile
  1002.     boolLog% = 0
  1003.  
  1004.     if RebootSystem = 0 then
  1005.         if RestartListEmpty = 1 then
  1006.             i% = DoMsgBox("Shanghai Great Moments may not run correctly until you restart Windows.", "Unable to Restart Windows", MB_ICONEXCLAMATION+MB_OK+MB_TASKMODAL)
  1007.         else
  1008.             i% = DoMsgBox("Fatal install failure. Please reinstall Shanghai Great Moments.", "Unable to Restart Windows", MB_ICONEXCLAMATION+MB_OK+MB_TASKMODAL)
  1009.         endif
  1010.     endif
  1011.     end '' End script
  1012.  
  1013. '*----------------------------------------------------------------------------*
  1014. '*
  1015. '* Fatal error handler for error message routine
  1016. '*
  1017. '*----------------------------------------------------------------------------*
  1018. ERRQUIT:
  1019.     i% = DoMsgBox("Setup sources were corrupted!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  1020.     end '' End script
  1021.  
  1022. '*----------------------------------------------------------------------------*
  1023. '*
  1024. '* Bypass run-time errors. Let final dialog box display fatal error message.
  1025. '*
  1026. '*----------------------------------------------------------------------------*
  1027. ERRNORMAL:
  1028.     '' Check if user cancelled setup
  1029.     if ERR = STFQUIT then
  1030.         goto QUIT
  1031.     endif
  1032.     RESUME NEXT
  1033.  
  1034.  
  1035. '*----------------------------------------------------------------------------*
  1036. '*
  1037. '* func:    Presents user with a 'bad path' msgbox
  1038. '*
  1039. '*
  1040. '*----------------------------------------------------------------------------*
  1041. BadPath:
  1042.     sz$ = UIStartDlg(CUIDLL$, dlgBADPATH, "FInfo0DlgProc", 0, "")
  1043.     if sz$ = "REACTIVATE" then
  1044.         goto BADPATH
  1045.     endif
  1046.     UIPop 1
  1047.     return
  1048.  
  1049. '*----------------------------------------------------------------------------*
  1050. '*
  1051. '* func:    Presents user with a 'insufficient space' msgbox
  1052. '*
  1053. '*
  1054. '*----------------------------------------------------------------------------*
  1055. BadDriveSpace:
  1056.     sz$ = UIStartDlg(CUIDLL$, dlgBADDISKSPACE, "FInfo0DlgProc", 0, "")
  1057.     if sz$ = "REACTIVATE" then
  1058.         goto BadDriveSpace
  1059.     endif
  1060.     UIPop 1
  1061.     return
  1062.  
  1063. '*----------------------------------------------------------------------------*
  1064. '*
  1065. '* func:    Presents user with a 'bad drive' msgbox
  1066. '*
  1067. '*
  1068. '*----------------------------------------------------------------------------*
  1069. BadDrive:
  1070.     sz$ = UIStartDlg(CUIDLL$, dlgBADDRIVE, "FInfo0DlgProc", 0, "")
  1071.     if sz$ = "REACTIVATE" then
  1072.         goto BADDRIVE
  1073.     endif
  1074.     UIPop 1
  1075.     return
  1076.  
  1077. '*----------------------------------------------------------------------------*
  1078. '*
  1079. '* func:    Provide an abort install dialog box
  1080. '*
  1081. '* rets:    Returns to caller if user chose to continue
  1082. '*          otherwise, script (install process) is terminated
  1083. '*
  1084. '*----------------------------------------------------------------------------*
  1085. AskQuit:
  1086.     sz$ = UIStartDlg(CUIDLL$, dlgASKQUIT, "FQuitDlgProc", 0, "")
  1087.  
  1088.     if sz$ = "EXIT" then
  1089.         UIPopAll
  1090.         ERROR STFQUIT
  1091.     elseif sz$ = "REACTIVATE" then
  1092.         goto AskQuit
  1093.     else
  1094.         UIPop 1
  1095.     endif
  1096.     return
  1097.  
  1098.  
  1099.  
  1100. '*----------------------------------------------------------------------------*
  1101. '*
  1102. '* func:    Builds the copy list for the required Win32 files
  1103. '*          and copies to destination directories
  1104. '*          (also removes any outdated files)
  1105. '*
  1106. '*
  1107. '*
  1108. '*----------------------------------------------------------------------------*
  1109. sub InstallWin32sFiles STATIC
  1110.     ClearCopyList
  1111.     W32SAddToCopyList
  1112.     CopyFilesInCopyList
  1113.     ClearCopyList
  1114. end sub
  1115.  
  1116. '*----------------------------------------------------------------------------*
  1117. '*
  1118. '* func:    Builds the copy list for the required SHGM files
  1119. '*          and copies to destination directories
  1120. '*
  1121. '*
  1122. '*----------------------------------------------------------------------------*
  1123. sub InstallSHGMFiles STATIC
  1124.     ClearCopyList
  1125.     SHGMAddToCopyList
  1126.     CopyFilesInCopyList
  1127.     ClearCopyList
  1128. end sub
  1129.  
  1130. '*----------------------------------------------------------------------------*
  1131. '*
  1132. '* func:    Builds the copy list for the required Win32 files
  1133. '*          and copies to destination directories
  1134. '*          (also removes any outdated files)
  1135. '*
  1136. '*
  1137. '*
  1138. '*----------------------------------------------------------------------------*
  1139. sub InstallWinGFiles STATIC
  1140.     ClearCopyList
  1141.     WINGAddToCopyList
  1142.     CopyFilesInCopyList
  1143.     ClearCopyList
  1144. end sub
  1145.  
  1146. '*----------------------------------------------------------------------------*
  1147. '*
  1148. '*----------------------------------------------------------------------------*
  1149.  
  1150. function RebootSystem STATIC AS INTEGER
  1151.     '' ExitExecRestart() will restart Windows, cleanup setup
  1152.     '' files, and copy over locked files before Windows restarts.
  1153.     ''
  1154.     i% = RestartListEmpty()
  1155.     if i% = 0 then
  1156.         '' ExitExecRestart() only returns if applications refuse to be shutdown.
  1157.         '' Win32s is installed but will not operate until Windows is restarted
  1158.         '' and the Win32s VxD is loaded.
  1159.         ''
  1160.         i% = ExitExecRestart()
  1161.         RebootSystem = 0
  1162.     else
  1163.         '' If the RestartList list is empty, it is necessary to restart windows
  1164.         '' directly.  The MSSETUP program creates _MSRSTRT.EXE and _MSSETUP.BAT
  1165.         '' in the restart directory.  This program should be exec'd to handle
  1166.         '' proper MSSETUP cleanup (temp files) and restart Windows.
  1167.         ''
  1168.         i% = ExitWindowsExec( GetWindowsDir() + "_MSRSTRT.EXE", "_MSSETUP.BAT" )
  1169.         RebootSystem = 0
  1170.     endif
  1171. end function
  1172.  
  1173.  
  1174. '*----------------------------------------------------------------------------*
  1175. '*
  1176. '* func:    Appends a file name to the end of a directory path,
  1177. '*          inserting a backslash character as needed.
  1178. '*
  1179. '*
  1180. '* args:    szDir$  - full directory path (with optional ending "\")
  1181. '*          szFile$ - filename to append to directory
  1182. '*
  1183. '* rets:    Resulting fully qualified path name.
  1184. '*
  1185. '*----------------------------------------------------------------------------*
  1186. function MakePath (szDir$, szFile$) STATIC AS STRING
  1187.     if szDir$ = "" then
  1188.         MakePath = szFile$
  1189.     elseif szFile$ = "" then
  1190.         MakePath = szDir$
  1191.     elseif MID$(szDir$, LEN(szDir$), 1) = "\" then
  1192.         MakePath = szDir$ + szFile$
  1193.     else
  1194.         MakePath = szDir$ + "\" + szFile$
  1195.     endif
  1196. end function
  1197.  
  1198. '*----------------------------------------------------------------------------*
  1199. '*
  1200. '*
  1201. '*
  1202. '*
  1203. '*----------------------------------------------------------------------------*
  1204. sub dputs(arg1$) static
  1205. '$ifdef MYDEBUG
  1206.     i% = OutputDebugString(arg1$+chr$(13)+chr$(10))
  1207. '$endif
  1208.     '' Also print out to log file
  1209.     if boolLog% <> 0 then
  1210.         WriteToLogFile arg1$
  1211.     endif
  1212. end sub
  1213.  
  1214. '*----------------------------------------------------------------------------*
  1215. '*
  1216. '*
  1217. '*
  1218. '*
  1219. '*----------------------------------------------------------------------------*
  1220. function DoesSectionFilesExist(szSection$,szDirPath$,dlgId%) static as integer
  1221.     '' find out if the directory where the files should be actually exists
  1222.     result% = 0
  1223.     CursorSave% = ShowWaitCursor()
  1224. DSFE1:
  1225.     sz$ = UIStartDlg(CUIDLL$,dlgID%,"FModelessDlgProc", 0, "")
  1226.     if sz$ = "REACTIVATE" then
  1227.         goto DSFE1
  1228.     endif
  1229.  
  1230.     dputs("Checking if following directory already exists")
  1231.     dputs("Directory: " + szDirPath$)
  1232.     if DoesDirExist(szDirPath$) = 0 then
  1233.         dputs("Above directory does not already exist")
  1234.         goto DSFE
  1235.     endif
  1236.     dputs("Yes, the above directory already exists")
  1237.  
  1238.     '' make a list of the necessary Win32s files in the Win32s directory
  1239.     ''
  1240.     MakeListFromSectionKeys "MY_LIST" , szSection$
  1241.     numFiles% = GetListLength("MY_LIST")
  1242.     result% = 1
  1243.  
  1244.     '' now make sure every file exists
  1245.     dputs("Now checking to see if following files exist in above directory")
  1246.     for i% = 1 to numFiles% step 1
  1247.         currItem$ = GetListItem("MY_LIST",i%)
  1248.         dputs("- " + currItem$)
  1249.         if DoesFileExist(szDirPath$ + currItem$, femExists) = 0 then
  1250.             dputs("  *MISSING*")
  1251.             result = 0
  1252.         else
  1253.             dputs("  found")
  1254.         endif
  1255.     next i%
  1256.  
  1257.     if (result% = 1) then
  1258.         dputs("All of the above files were present")
  1259.     else
  1260.         dputs("One or more of the above files were missing")
  1261.     endif
  1262.  
  1263. DSFE:
  1264.     UIPop 1
  1265.     RestoreCursor CursorSave%
  1266.     SetSymbolValue "MY_LIST", ""
  1267.     currFile$ = ""
  1268.     DoesSectionFilesExist = result%
  1269. end function
  1270.  
  1271.  
  1272. '' Stuff to determine 256 color capability
  1273. const RASTERCAPS   = 38
  1274. const BITSPIXEL    = 12
  1275. const RC_PALETTE   = 256
  1276.  
  1277. declare function GetDC LIB "USER.EXE" (arg1%) as integer
  1278. declare function ReleaseDC LIB "USER.EXE" (arg1%,arg2%) as integer
  1279. declare function GetDeviceCaps LIB "GDI.EXE" (arg1%,arg2%) as integer
  1280.  
  1281.  
  1282. '*----------------------------------------------------------------------------*
  1283. '*
  1284. '*
  1285. '*
  1286. '*
  1287. '*----------------------------------------------------------------------------*
  1288. function Have256Colors static as integer
  1289.     Have256Colors = 0
  1290.  
  1291.     '' Obtain system DC
  1292.     hDC% = GetDC(0)
  1293.  
  1294.     tmpInt% = GetDeviceCaps(hDC%,RASTERCAPS)
  1295.  
  1296.     if (tmpInt% and RC_PALETTE) then
  1297.         tmpInt% = GetDeviceCaps(hDC%,BITSPIXEL)
  1298.         if (tmpInt% = 8) then
  1299.             Have256Colors = 1
  1300.         endif
  1301.     endif
  1302.     tmpInt% = ReleaseDC(0,hDC%)
  1303.  
  1304. end function
  1305.  
  1306.  
  1307.  
  1308. '*----------------------------------------------------------------------------*
  1309. '*
  1310. '*
  1311. '*
  1312. '*
  1313. '*----------------------------------------------------------------------------*
  1314. function ConfirmDialog(dlgID%) static as integer
  1315. CF1:
  1316.     sz$ = UIStartDlg(CUIDLL$,dlgID%,"FInfoDlgProc", 0, "")
  1317.     if sz$ = "CONTINUE" then
  1318.         ConfirmDialog = 1
  1319.         UIPop 1
  1320.     elseif sz$ = "REACTIVATE" then
  1321.         goto CF1
  1322.     else
  1323.         ConfirmDialog = 0
  1324.         UIPop 1
  1325.     endif
  1326. end function
  1327.  
  1328. '*----------------------------------------------------------------------------*
  1329. '*
  1330. '*
  1331. '*
  1332. '*
  1333. '*----------------------------------------------------------------------------*
  1334. sub W32SAddToCopyList static
  1335.     '' Add Win32s files
  1336.     AddSectionFilesToCopyList "WindowsSystem", SrcDir$, dirWinSys$
  1337.     AddSectionFilesToCopyList "WindowsSystemWin32s", SrcDir$, dirWinSys$ + "WIN32S\"
  1338.     '' Add obsolete files to be removed
  1339.     ''
  1340.     AddSectionFilesToCopyList "Win32sSystemObsoleteFiles", SrcDir$, dirWinSys$ + "WIN32S\"
  1341. end sub
  1342.  
  1343. '*----------------------------------------------------------------------------*
  1344. '*
  1345. '*
  1346. '*
  1347. '*
  1348. '*----------------------------------------------------------------------------*
  1349. function InstallVFlatD static as integer
  1350.     InstallVFLatD = 0
  1351.  
  1352.     '' only use DVA on Windows 3.x
  1353.     ''
  1354.     if onWin31% = 1 then
  1355.         dputs("Checking to see if VFlatD is installed (DVA.386)")
  1356.         if VflatdPresent() = 0 then
  1357.             dputs("VFlatD is not present (DVA.386 driver)")
  1358.             InstallVFlatD = 1
  1359.         else
  1360.             dputs("VFlatD is already installed (DVA.386)")
  1361.         endif
  1362.     endif
  1363. end function
  1364.  
  1365. '*----------------------------------------------------------------------------*
  1366. '*
  1367. '*
  1368. '*
  1369. '*
  1370. '*----------------------------------------------------------------------------*
  1371. sub WINGAddToCopyList static
  1372.     AddSectionFilesToCopyList "WinG", SrcDir$, dirWinSys$
  1373.     if InstallVFlatD <> 0 then
  1374.         AddSectionFilesToCopyList "dva", SrcDir$, dirWinSys$
  1375.     endif
  1376. end sub
  1377.  
  1378. '*----------------------------------------------------------------------------*
  1379. '*
  1380. '*
  1381. '*
  1382. '*
  1383. '*----------------------------------------------------------------------------*
  1384. sub SHGMAddToCopyList static
  1385.     AddSectionFilesToCopyList "SHGM", SrcDir$, dirSHGM$
  1386. end sub
  1387.  
  1388.  
  1389.