home *** CD-ROM | disk | FTP | other *** search
/ CD/PC Actual 4 / CD_ACTUAL_4.iso / edinst / setup.ms_ / setup.ms
Encoding:
Text File  |  1996-07-10  |  43.8 KB  |  1,290 lines

  1. '$DEFINE DEBUG
  2.  
  3. '$INCLUDE 'setupapi.inc'
  4. '$INCLUDE 'msdetect.inc'
  5.  
  6. CONST TITLE                     = "La Hora y Lugar en la Casa de Trudy"
  7. CONST INSERTCD                  = "La Hora y Lugar en la Casa de Trudy "
  8. CONST INIFILE                   = "Edmark.INI"
  9. CONST PROGRAMTITLE              = "La Hora y Lugar en la Casa de Trudy"
  10. CONST READMETITLE               = "Registration Information"
  11. CONST HELPTITLE                 = "La Hora y Lugar en la Casa de Trudy Help"
  12. CONST SECTION                   = "TRUDY"
  13. CONST TRUDYDIR                    = "TRUDY\"
  14. CONST EDUTILDIR                 = "\EDUTIL\"
  15. CONST WING                      = "WING\"
  16. CONST HELPPATH                  = "~:\TRUDY\TRUDY3.hlp"
  17. CONST READMEPATH                = "~:\edinst\win10k.wri"
  18. CONST DEARPARENTSPATH           = "~:\TRUDY\dearpar\dearpar.exe"
  19. CONST DEARPARENTSICON           = "dearpar.ico"
  20. CONST READMEICON                = "win10k.ico"
  21. CONST DEMOPATH                  = "DEMO\DEMO.EXE"
  22. CONST DEMOICON                  = "DEMO\DEMO.ico"
  23. CONST DEMOTITLE                 = "Demo"
  24. CONST HELPICON                  = "TRUDY3.ico"
  25. CONST EXEICON                   = "TRUDY.ico"
  26. CONST EXENAME                   = "TRUDY.exe"
  27.  
  28. ''DIALOG ID's
  29. CONST WELCOME                    = 100
  30. CONST ASKQUIT                    = 200
  31. CONST DESTPATH                   = 300
  32. CONST EXITFAILURE                = 400
  33. CONST EXITQUIT                   = 600
  34. CONST EXITSUCCESS                = 700
  35. CONST VERIFYWINPATH              = 2400
  36. CONST ERROR_UNEXPECTED           = 2200
  37. CONST EXITSUCCESSRESTART         = 2300
  38. CONST NOVIRTUALMEM               = 2600
  39. CONST ASKRESTART                 = 2700
  40. CONST RESTART                    = 2800
  41. CONST README                     = 2900
  42. CONST NOSHAREENABLED               = 3000
  43. CONST NEEDREBOOT                = 3100
  44. CONST CUSTINST                   = 6200
  45.  
  46. ''OTHER CONSTANTS
  47. CONST LOGO                       = 1
  48. CONST EXIT_FAIL_NOT31            = 1500   '' AT LEAST WINDOWS 3.1
  49. CONST EXIT_FAIL_NOTINTEL         = 1600   '' NOT INTEL
  50. CONST EXIT_FAIL_NOTENHANCED      = 1700   '' NOT ENHANCED MODE
  51. CONST MB_YESNO                   = 4
  52. CONST MB_ICONINFORMATION         = 64
  53. CONST IDYES                      = 6
  54. CONST IDNO                       = 7
  55. CONST MB_OKCANCEL               = 1
  56. CONST IDOK                      = 1
  57.  
  58. GLOBAL DESTWIN$         ''Windows dir
  59. GLOBAL DESTWINSYS$      ''Windows\System dir
  60. GLOBAL DESTDIR$       ''Diner directory
  61. GLOBAL SrcDrive$
  62. GLOBAL DestEdUtilDir$
  63. GLOBAL bInstallDVA%
  64. GLOBAL DEARPARENTS$
  65. GLOBAL READMESTR$
  66. GLOBAL HELP$
  67. GLOBAL DPICON$
  68. GLOBAL RMICON$
  69. GLOBAL HICON$
  70. GLOBAL SHAREMISSING%
  71.  
  72. ''WIN32S Stuff
  73. CONST TF_FORCEDRIVE            = 128
  74. GLOBAL DEST32S$      ''Windows\System\Win32s directory
  75. GLOBAL OLE_PROTECT%  ''Indicates whether ole2 dlls were protected from being
  76.              '' copied.
  77. GLOBAL OLE_OLEBOOT%
  78. GLOBAL VERNUM$       '' Win32s Version Number (i.e., for v1.25 VERNUM$="125"
  79.  
  80. GLOBAL szOldVer$
  81. GLOBAL WIN32ENABLED%
  82. GLOBAL OLEONLY%
  83. GLOBAL OLE2_16%
  84. GLOBAL OLE2AUTO_16%
  85. GLOBAL OLE16RUNAPP%
  86. GLOBAL OLEINCLUDED%
  87. GLOBAL OLE2_32%
  88. GLOBAL szOleNewVer$
  89. GLOBAL szOleOldVer$
  90. GLOBAL szOle16OldVer$
  91. GLOBAL szOle16NewVer$
  92. ''End Win32s stuff
  93.  
  94. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  95. DECLARE SUB      UpdateWinG32 (szOrig$)
  96.  
  97. DECLARE FUNCTION OnWin3x            LIB "setuphlp.DLL" AS INTEGER
  98. DECLARE FUNCTION VflatdPresent      LIB "setuphlp.DLL" AS INTEGER
  99. DECLARE FUNCTION RestartWindows     LIB "setuphlp.DLL" AS INTEGER
  100. DECLARE FUNCTION IsWin32FileNewer   LIB "setuphlp.DLL" (szOrig$,szNew$) AS INTEGER
  101. DECLARE SUB      RenameFilePlease   LIB "setuphlp.DLL" (szOrig$,szNew$)
  102. DECLARE FUNCTION OnWindowsNT     LIB "INIUPD.DLL" AS INTEGER
  103. DECLARE FUNCTION PagingEnabled   LIB "INIUPD.DLL" AS INTEGER
  104. DECLARE FUNCTION ExitWindowsExec LIB "USER.EXE" (arg1$, arg2$) AS INTEGER
  105. DECLARE FUNCTION StartWaitCursor LIB "MSCUISTF.DLL" AS INTEGER
  106. DECLARE FUNCTION StopWaitCursor  LIB "MSCUISTF.DLL" AS INTEGER
  107.  
  108. ''Win32s function declarations
  109. DECLARE FUNCTION AddWin32sToFakeCopyList AS INTEGER
  110. DECLARE FUNCTION CopyWin32sFiles AS INTEGER
  111. DECLARE SUB InstallWin32s(OLEONLY%, OLE2_32%, OLE2_16%, OLE2AUTO_16%, OLE16RUNAPP%)
  112. DECLARE SUB RecoverFromCopy(szFileName$)
  113. DECLARE SUB UpdateSystemIni
  114. DECLARE FUNCTION RebootSystem(ONLY_IF_RESTART_NOT_EMPTY%) AS INTEGER
  115. DECLARE FUNCTION MakeSystemIni LIB "INIUPD2.DLL" (arg1$, arg2$) AS INTEGER
  116. DECLARE FUNCTION ShareEnabled LIB "INIUPD2.DLL" AS INTEGER
  117. DECLARE FUNCTION IsWin32sLoaded LIB "INIUPD2.DLL" (arg1$) AS INTEGER
  118. DECLARE FUNCTION IsRunningApp LIB "INIUPD2.DLL" AS INTEGER
  119. DECLARE FUNCTION SetCuiFlags LIB "MSCUISTF.DLL" (arg1%, arg2%) AS INTEGER
  120. DECLARE FUNCTION GetModuleHandle LIB "KRNL386.EXE" (arg1$) AS INTEGER
  121. DECLARE FUNCTION LoadLibrary LIB "KRNL386.EXE" (arg1$) AS INTEGER
  122. DECLARE SUB FreeLibrary LIB "KRNL386.EXE" (arg1%)
  123. DECLARE FUNCTION SetErrorMode LIB "KRNL386.EXE" (arg1%) AS INTEGER
  124. DECLARE FUNCTION GetTempFileName LIB "KRNL386.EXE" (drive%, prefix$, u%, filename$) AS INTEGER
  125. DECLARE SUB WriteLine LIB "INIUPD2.DLL" (filename$, text$)
  126. DECLARE FUNCTION GetTempFileAt(szDir$, szPrefix$) as string
  127. ''End Win32s declarations
  128.  
  129. INIT:
  130.    CUIDLL$ = "MSCUISTF.DLL"
  131.    bInstallDVA% = 0
  132.    ExitCode% = 0
  133.    ON ERROR GOTO ERRORTRAP
  134.  
  135.    SHAREMISSING% = 0
  136.  
  137.    SrcDir$ = GetSymbolValue ("STF_SRCDIR")
  138.    DESTWIN$ = GetWindowsDir()
  139.    SrcDrive$ = MID$ (SrcDir$, 1,3)
  140.    DESTDIR$ = MID$ (DESTWIN$, 1,3)
  141.    DESTDIR$ =  DESTDIR + "EDMARK"
  142.    DestEdUtilDir$=DESTDIR$+EDUTILDIR
  143.  
  144.    SetBitmap CUIDLL$, LOGO
  145.    SetTitle PROGRAMTITLE
  146.    DestEdUtilDir$=DESTDIR$+EDUTILDIR
  147.    DESTDIR$=DESTDIR$+"\"+TRUDYDIR
  148.  
  149.    szInf$ = GetSymbolValue ("STF_SRCINFPATH")
  150.    IF szInf$ = "" THEN
  151.       szInf$ = GetSymbolValue ("STF_CWDDIR") + "setup.inf"
  152.    ENDIF
  153.    ReadInfFile szInf$
  154. CHECK:
  155.    '' Check to make sure we're running at least Win 3.1
  156.    IF GetWindowsMajorVersion < 3 THEN
  157.       ExitCode% = EXIT_FAIL_NOT31
  158.       GOTO WELCOME
  159.    ENDIF
  160.    IF GetWindowsMajorVersion = 3 AND GetWindowsMinorVersion < 1 THEN
  161.       ExitCode% = EXIT_FAIL_NOT31
  162.       GOTO WELCOME
  163.    ENDIF
  164.    '' Check to see that we're running in enhanced mode or on an INTEL-Based NT machine
  165.    '' GetWindowsMode < 2 means not INTEL if running NT, or not ENHANCED if running Windows
  166.    IF GetWindowsMode < 2 THEN
  167.       IF OnWindowsNT() THEN
  168.      ExitCode% = EXIT_FAIL_NOTINTEL
  169.       ELSE
  170.      ExitCode% = EXIT_FAIL_NOTENHANCED
  171.       ENDIF
  172.       GOTO WELCOME
  173.    ENDIF
  174. VIRTUALMEM:
  175.    '' Check to make sure windows is set up for virtual memory
  176.    IF PagingEnabled() = 0 THEN
  177.       sz$ = UIStartDlg (CUIDLL$, NOVIRTUALMEM, "FInfoDlgProc", 0, "")
  178.       IF sz$ = "REACTIVATE" THEN
  179.      GOTO VIRTUALMEM
  180.       ENDIF
  181.       UIPop 1
  182.       GOTO WELCOME
  183.    ENDIF
  184. WELCOME:
  185.    sz$ = UIStartDlg (CUIDLL$, WELCOME, "FInfoDlgProc", 0, "")
  186.  
  187.    IF sz$ <> "CONTINUE" THEN
  188.       GOSUB ASKQUIT
  189.       GOTO WELCOME
  190.    ENDIF
  191.  
  192.    UIPop 1     '' destroy dialog on top of stack
  193.  
  194.    IF ExitCode% <> 0 THEN
  195.       GOTO EXITFAIL
  196.    ENDIF
  197. VERIFYWINPATH:
  198.    '' Verify that setup has found the correct \windows directory
  199.    SetSymbolValue "EditTextIn", DESTWIN$
  200.    SetSymbolValue "EditFocus", "END"
  201.    sz$ = UIStartDlg (CUIDLL$, VERIFYWINPATH, "FEditDlgProc", 0, "")
  202.    IF sz$ = "REACTIVATE" THEN
  203.       GOTO VERIFYWINPATH
  204.    ELSEIF SZ$ = "EXIT" THEN
  205.       GOSUB ASKQUIT
  206.       GOTO VERIFYWINPATH
  207.    ENDIF
  208.    sz$ = GetSymbolValue ("EditTextOut")
  209.    IF sz$ <> DESTWIN$ THEN
  210.  
  211.       '' make sure user ended path with a '\'
  212.       '' if not, help 'em out
  213.       DESTWIN$ = sz$
  214.       DESTWIN$ = LTRIM$(RTRIM$ (DESTWIN$))
  215.       IF INSTR (LEN (DESTWIN$) - 1, DESTWIN$, "\") = 0 THEN
  216.      DESTWIN$ = DESTWIN$ + "\"
  217.       ENDIF
  218.       '' make sure path has a drive letter and drive letter is valid
  219.       sz$ = MID$ (DESTWIN$, 2, 1)
  220.       IF sz$ <> ":" THEN
  221.      i% = DoMsgBox ("Aseg·rese que la ruta es vßlida.", TITLE, MB_ICONHAND + MB_OK)
  222.      GOTO VERIFYWINPATH
  223.       ENDIF
  224.       sz$ = MID$ (DESTWIN$, 1, 1)
  225.       IF IsDriveValid (sz$) = 0 THEN
  226.      i% = DoMsgBox ("Aseg·rese que la ruta es vßlida.", TITLE, MB_ICONHAND + MB_OK)
  227.      GOTO VERIFYWINPATH
  228.       ENDIF
  229.       '' make sure path is valid (i.e. it exists)
  230.       IF DoesDirExist (DESTWIN$) = 0 THEN
  231.      i% = DoMsgBox (" Ruta de acceso no vßlida!", TITLE, MB_ICONHAND + MB_OK)
  232.      GOTO VERIFYWINPATH
  233.       ENDIF
  234.    ENDIF
  235.  
  236.    UIPop 1
  237.  
  238.    DESTWINSYS$ = DESTWIN$
  239.    IF INSTR (LEN (DESTWINSYS$) - 1, DESTWINSYS$, "\") = 0 THEN
  240.       DESTWINSYS$ = DESTWINSYS$ + "\"
  241.    ENDIF
  242.    DESTWINSYS$ = DESTWINSYS$ + "SYSTEM\"
  243. INITCOPYLISTFORESTIMATE:
  244.    '' add possible files to copy list so we can get the copy list cost for the next dialog
  245.    '' (so we know how much space the files will take up)
  246.    '' after the next dialog, we'll rebuild an actual copy list
  247.    '' (we can't do it accurately yet since we don't know where the path will be)
  248.    '' NOTE: THIS CANNOT BE A FINAL COPY LIST AS SOME VITAL COMMANDS DON'T APPEAR -
  249.    ''       SEE FINAL COPY LIST SECTION BELOW
  250.  
  251.    i% = StartWaitCursor()
  252.    ClearCopyList
  253.  
  254.    AddSectionFilesToCopyList SECTION, SrcDrive$+TRUDYDIR, DESTDIR$
  255.    AddSectionFilesToCopyList "EDUTIL", SrcDir$, DestEdUtilDir$
  256.  
  257.    ''see if WAVEMIX.INI file already exists
  258.    '' if not, copy a pre-built one
  259.    IF DoesFileExist (DESTWIN$ + "WAVEMIX.INI", femExists) = 0 THEN
  260.       AddSectionFilesToCopyList "WaveMixIni", SrcDir$, DESTWIN$
  261.    ENDIF
  262.  
  263.    '' ********  WING SECTION STARTS HERE
  264.       AddSectionFilesToCopyList "WinG", SrcDir$+WING, DESTWINSYS$
  265.  
  266.       '
  267.       ' only use DVA on Windows 3.x
  268.       '
  269.       IF OnWin3x() = 1 THEN
  270.      AddSectionFilesToCopyList "dva", SrcDir$ + WING, DESTWINSYS$
  271.       END IF
  272.  
  273.       AddSectionFilesToCopyList "wing32", SrcDir$, DESTWINSYS$
  274.  
  275.    '' Add VfW files here
  276.    AddSectionFilesToCopyList "VfW Runtime", SrcDir$, DESTWINSYS$
  277.    AddSectionFilesToCopyList "AVICodecs", SrcDir$, DESTWINSYS$
  278.    AddSectionFilesToCopyList "ACM Drivers", SrcDir$, DESTWINSYS$
  279.    AddSectionFilesToCopyList "Indeo-ini", SrcDir$, DESTWIN$
  280. ''   AddSectionFilesToCopyList "OLE2", SrcDir$, DESTWINSYS$
  281.    AddSectionFilesToCopyList "MPlayer", SrcDir$, DESTWIN$
  282.    i% = AddWin32sToFakeCopyList()
  283.    IF i% <> EXITSUCCESS THEN
  284.        IF i% = EXITFAILURE THEN
  285.             GOTO FAILURE
  286.        ELSE
  287.             GOTO EXITFAIL
  288.        END IF
  289.    END IF
  290.    sizereq& = GetCopyListCost ("", "NeededSpace", "ExtraNeeded")
  291.  
  292.    i% = StopWaitCursor()
  293. CUSTOMINIT:
  294.    '' SET UP DRIVE AND DIRECTORY SYMBOL VALUES HERE
  295.    SetSymbolValue "DriveStatusText", ""
  296.    sz$ = MID$ (DESTDIR$, 1, 2)
  297.    AddListItem "DriveStatusText", sz$
  298.    sz$ = GetListItem ("NeededSpace", ASC(LCASE$ (DESTDIR$)) - ASC("a") + 1)
  299.    AddListItem "DriveStatusText", sz$
  300.    DinerSpaceAvail& = GetFreeSpaceForDrive (MID$ (DESTDIR$, 1, 1))
  301.    AddListItem "DriveStatusText", STR$ (DinerSpaceAvail&)
  302.    AddListItem "DriveStatusText", ""
  303.    AddListItem "DriveStatusText", ""
  304.    AddListItem "DriveStatusText", ""
  305.    AddListItem "DriveStatusText", DESTDIR$
  306. CUSTOM:
  307.    '' Get drive and directory to install product to
  308.    sz$ = UIStartDlg (CUIDLL$, CUSTINST, "FCustInstDlgProc", 0, "")
  309.    IF sz$ = "REACTIVATE" THEN
  310.       GOTO CUSTOM
  311.    ELSEIF sz$ = "BACK" THEN
  312.       UIPop 1
  313.       GOTO VERIFYWINPATH
  314.    ELSEIF sz$ = "EXIT" THEN
  315.       GOSUB ASKQUIT
  316.       GOTO CUSTOM
  317.    ELSEIF sz$ = "PATH" THEN
  318.       TEMPDINER$ = DESTDIR$
  319. GETDINERPATH:
  320.       '' Let user choose own path for Diner
  321.       SetSymbolValue "EditTextIn", TEMPDINER$
  322.       SetSymbolValue "EditFocus", "ALL"
  323.       sz$ = UIStartDlg (CUIDLL$, DESTPATH, "FEditDlgProc", 0, "")
  324.       IF sz$ = "REACTIVATE" THEN
  325.      GOTO GETDINERPATH
  326.       ELSEIF sz$ = "BACK" THEN
  327.      UIPop 1
  328.      GOTO CUSTOM
  329.       ELSEIF sz$ = "EXIT" THEN
  330.      GOSUB ASKQUIT
  331.      GOTO GETDINERPATH
  332.       ENDIF
  333.       sz$ = GetSymbolValue ("EditTextOut")
  334.       '' make sure user ended path with a '\'
  335.       '' if not, help 'em out
  336.       TEMPDINER$ = LTRIM$ (RTRIM$ (sz$))
  337.       IF INSTR (LEN (TEMPDINER$) - 1, TEMPDINER$, "\") = 0 THEN
  338.      TEMPDINER$ = TEMPDINER$ + "\"
  339.       ENDIF
  340.       '' make sure path has a drive letter and drive letter is valid
  341.       sz$ = MID$ (TEMPDINER$, 2, 1)
  342.       IF sz$ <> ":" THEN
  343.      i% = DoMsgBox ("Aseg·rese que la ruta es vßlida.", TITLE, MB_ICONHAND + MB_OK)
  344.      GOTO GETDINERPATH
  345.       ENDIF
  346.       sz$ = MID$ (TEMPDINER$, 1, 1)
  347.       IF IsDriveValid (sz$) = 0 THEN
  348.      i% = DoMsgBox ("Aseg·rese que la ruta es vßlida.", TITLE, MB_ICONHAND + MB_OK)
  349.      GOTO GETDINERPATH
  350.       ENDIF
  351.       '' make sure path is valid
  352.       IF IsDirWritable (TEMPDINER$) = 0 THEN
  353.      i% = DoMsgBox ("Ruta de acceso no vßlida.", TITLE, MB_ICONHAND + MB_OK)
  354.      GOTO GETDINERPATH
  355.       ENDIF
  356.       UIPop 1
  357.       DESTDIR$ = TEMPDINER$
  358.       GOTO INITCOPYLISTFORESTIMATE
  359.    ENDIF
  360.  
  361.    UIPop 1
  362. CHECKSPACE:
  363.    amt$ = GetListItem ("ExtraNeeded", ASC(LCASE$ (DESTDIR$)) - ASC("a") + 1)
  364.    amt$ = MID$ (amt$, 1, 1)
  365.    IF amt$ <> "-" THEN
  366.       i% = DoMsgBox ("No hay suficiente espacio en la unidad.", TITLE, MB_ICONHAND + MB_OK)
  367.       GOTO CUSTOM
  368.    ENDIF
  369.  
  370.    amt$ = GetListItem ("ExtraNeeded", ASC(LCASE$ (DESTWIN$)) - ASC("a") + 1)
  371.    amt$ = MID$ (amt$, 1, 1)
  372.    IF amt$ <> "-" THEN
  373.       i% = DoMsgBox ("No hay suficiente espacio en la unidad de Windows.", TITLE, MB_ICONHAND + MB_OK)
  374.       GOTO SEEYA
  375.    ENDIF
  376. INITREALCOPYLIST:
  377.    '' add files to copy list
  378.    ClearCopyList
  379.  
  380.    RESTARTDIR$ = DESTWIN$
  381.    SetRestartDir RESTARTDIR$
  382.  
  383.    i% = CopyWin32sFiles()
  384.    IF i%=EXITERROR THEN
  385.       GOTO ERR_UNEXPECTED
  386.    END IF
  387.    IF i%<>EXITSUCCESS THEN
  388.       GOTO FAILURE
  389.    END IF
  390.    ClearCopyList
  391.  
  392.    AddSectionFilesToCopyList SECTION, SrcDrive$+TRUDYDIR, DESTDIR$
  393.    AddSectionFilesToCopyList "EDUTIL", SrcDir$, DestEdUtilDir$
  394.  
  395.    '' see if DINER.INI file already exists
  396.    '' if not, copy a base INI file
  397. ''   IF DoesFileExist (DESTWIN$ + INIFILE, femExists) = 0 THEN
  398. ''      AddSectionFilesToCopyList "INI", SrcDir$, DESTWIN$
  399. ''   ENDIF
  400.  
  401.    '' see if WAVEMIX.INI file already exists
  402.    '' if not, copy a pre-built one
  403.    IF DoesFileExist (DESTWIN$ + "WAVEMIX.INI", femExists) = 0 THEN
  404.       AddSectionFilesToCopyList "WaveMixIni", SrcDir$, DESTWIN$
  405.    ENDIF
  406.  
  407.    '' ********  WING SECTION STARTS HERE
  408.       AddSectionFilesToCopyList "WinG", SrcDir$, DESTWINSYS$
  409.  
  410.       '
  411.       ' only use DVA on Windows 3.x
  412.       '
  413.       IF OnWin3x() = 1 THEN
  414.      AddSectionFilesToCopyList "dva", SrcDir$, DESTWINSYS$
  415.      IF VflatdPresent() = 0 THEN
  416.         bInstallDVA% = 1
  417.      END IF
  418.       END IF
  419.  
  420.       AddSectionFilesToCopyList "wing32", SrcDir$, DESTWINSYS$
  421.      Dest1$ = MakePath(DESTWINSYS$,"wing32.dll")
  422.      Dest2$ = MakePath(DESTWINSYS$,"wing32.xxx")
  423.       RenameFilePlease Dest1$,Dest2$
  424.  
  425.    '' Add VfW files here
  426.    AddSectionFilesToCopyList "VfW Runtime", SrcDir$, DESTWINSYS$
  427.    AddSectionFilesToCopyList "AVICodecs", SrcDir$, DESTWINSYS$
  428.    AddSectionFilesToCopyList "ACM Drivers", SrcDir$, DESTWINSYS$
  429.    AddSectionFilesToCopyList "Indeo-ini", SrcDir$, DESTWIN$
  430. ''   AddSectionFilesToCopyList "OLE2", SrcDir$, DESTWINSYS$
  431.    AddSectionFilesToCopyList "MPlayer", SrcDir$, DESTWIN$
  432. COPYFILES:
  433.    SrcDir$ = GetSymbolValue ("STF_SRCDIR")
  434.    CreateDir DESTDIR$, cmoVital
  435. ''   CreateDir DESTDIR$ + "TRUDY\", cmoVital
  436.    ERR = 0
  437.    IF SHAREMISSING% = 1 THEN
  438.      i% = DoMsgBox (TITLE + " recomienda que se a±ada el archivo SHARE.EXE al AUTOEXEC.BAT.", TITLE, MB_ICONHAND + MB_OK)
  439.    END IF
  440.    '' copy the files
  441.    CopyFilesInCopyList
  442.  
  443.    '' update wing32
  444.    UpdateWinG32 DESTWINSYS$
  445.  
  446.    '' if we needed to install DVA, create an INI key value
  447.    IF bInstallDVA% = 1 THEN
  448.       CreateSysIniKeyValue DESTWIN$ + "system.ini", "386Enh", "device", MakePath(DESTWINSYS$, "dva.386"), cmoOverwrite
  449.    ENDIF
  450.  
  451.    '' update VfW stuff
  452.    CreateIniKeyValue DESTWIN$ + INIFILE, TITLE, "Resource Path", SrcDrive$, cmoOverwrite
  453.    CreateIniKeyValue DESTWIN$ + INIFILE, TITLE, "ExePath", DESTDIR$ + EXENAME, cmoOverwrite
  454.    CreateIniKeyValue DESTWIN$ + "system.ini", "Drivers", "VIDC.CVID", "iccvid.drv", cmoOverwrite
  455.    CreateIniKeyValue DESTWIN$ + "system.ini", "Drivers", "VIDC.MSVC", "msvidc.drv", cmoOverwrite
  456.    CreateIniKeyValue DESTWIN$ + "system.ini", "Drivers", "VIDC.IV31", "ir32.dll", cmoOverwrite
  457.    CreateIniKeyValue DESTWIN$ + "system.ini", "Drivers", "VIDC.IV32", "ir32.dll", cmoOverwrite
  458.    CreateIniKeyValue DESTWIN$ + "system.ini", "Drivers", "VIDC.MRLE", "MSRLE.drv", cmoOverwrite
  459.    I% = DoesIniKeyExist (DESTWIN$ + "system.ini", "Drivers", "VIDC.RT21")
  460.    IF I% = 0  THEN
  461.       CreateIniKeyValue DESTWIN$ + "system.ini", "Drivers", "VIDC.RT21", "indeov.drv", cmoOverwrite
  462.    END IF
  463.    CreateIniKeyValue DESTWIN$ + "system.ini", "Drivers", "VIDC.YVU9", "indeov.drv", cmoOverwrite
  464.    CreateIniKeyValue DESTWIN$ + "WIN.INI", "mci extensions", "avi", "AVIVideo", cmoOverwrite
  465.    CreateIniKeyValue DESTWIN$ + "system.ini", "mci", "AVIVideo", "mciavi.drv", cmoOverwrite
  466.    CreateIniKeyValue DESTWIN$ + "system.ini", "Drivers", "WaveMapper", "msacm.drv", cmoOverwrite
  467.    CreateIniKeyValue DESTWIN$ + "system.ini", "Drivers", "MSACM.msadpcm", "msadpcm.acm", cmoOverwrite
  468.    CreateIniKeyValue DESTWIN$ + "system.ini", "Drivers", "MSACM.imaadpcm", "imaadpcm.acm", cmoOverwrite
  469.    CreateIniKeyValue DESTWIN$ + "control.ini", "drivers.desc", "msacm.drv", "Microsoft Sound Mapper V2.00", cmoOverwrite
  470.    CreateIniKeyValue DESTWIN$ + "control.ini", "drivers.desc", "msadpcm.acm", "Microsoft ADPCM Codec V2.00", cmoOverwrite
  471.    CreateIniKeyValue DESTWIN$ + "control.ini", "drivers.desc", "imaadpcm.acm", "Microsoft IMA ADPCM Codec V2.00", cmoOverwrite
  472.  
  473.    '' check for copy errors
  474.    IF ERR <> 0 THEN
  475.       GOTO ERR_UNEXPECTED
  476.    ENDIF
  477.  
  478.    '' more VfW stuff
  479.    Run ("regedit.exe /s " + MakePath(DESTWIN$, "mplayer.reg"))
  480. ''   Run ("regedit.exe /s " + MakePath(DESTWINSYS$, "OLE2.reg"))
  481. ''   Run ("regedit.exe /s " + MakePath(DESTWINSYS$, "cleanup.reg"))
  482.   EICON$ = DESTDIR$+EXEICON
  483.    '' add program manager group and item icon
  484.    CreateProgmanGroup "Edmark", "", cmoNone
  485.  
  486.  
  487.    '' Delete the items first since setup seems to have a bug so it won't overwrite if you specify an icon
  488.    Run("delitem.exe " + TITLE)
  489.  CreateProgmanItem "Edmark", TITLE, DESTDIR$ + EXENAME, EICON$, cmoOverwrite
  490.  
  491.  
  492. ''   CreateProgramItem "Edmark", DEARPARENTS,
  493.    ShowProgmanGroup "Edmark", 1, cmoNone
  494.  
  495.    Run ("profdisp.exe")
  496. READMEDLG:
  497.    sz$ = UIStartDlg (CUIDLL$, README, "FInfoDlgProc", 0, "")
  498.    IF sz$ = "REACTIVATE" THEN
  499.       GOTO READMEDLG
  500.    ENDIF
  501.    UIPop 1
  502. SUCCESS:
  503. '' HERE WE ALMOST CERTAINLY NEED TO RESTART WINDOWS (and possibly reboot the machine)
  504. '' BECAUSE OF THE WIN32S STUFF
  505. '' IF IT WAS ALREADY INSTALLED AND WE DIDN'T INSTALL ANY DVA STUFF, THEN WE DON'T
  506. '' NEED TO REBOOT
  507.    '' indicate success to the user and restart windows if necessary
  508.    sz$ = UIStartDlg (CUIDLL$, EXITSUCCESS, "FInfoDlgProc", 0, "")
  509.    IF sz$ = "REACTIVATE" THEN
  510.       GOTO SUCCESS
  511.    ENDIF
  512.    UIPop 1
  513. DOIT:
  514.    ''make sure we run share if necessary before we start windows up after
  515.    ''we exit out
  516.  
  517.    FOR_APP% = (WIN32ENABLED% and not bInstallDVA)
  518.    FOR_W32S% = (OLEONLY% and not OLE_OLEBOOT% and not bInstallDVA)
  519.    IF RebootSystem(FOR_APP% or FOR_W32S%) = 0 THEN
  520.       dummy% = DoMsgBox ("Salga de MS-DOS y haga clic en OK.", TITLE, MB_OK + MB_ICONHAND)
  521.       goto DOIT
  522.    END IF
  523.    GOTO SEEYA
  524.  
  525. ASKQUIT:
  526.    sz$ = UIStartDlg (CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  527.  
  528.    IF sz$ = "EXIT" THEN
  529.       UIPop 1
  530.       GOTO QUIT
  531.    ELSEIF sz$ = "REACTIVATE" THEN
  532.       GOTO ASKQUIT
  533.    ELSE
  534.       UIPop 1                 '' remove quit dialog and go back to previous dialog
  535.    ENDIF
  536.    RETURN
  537. QUIT:
  538.    sz$=  UIStartDlg (CUIDLL$, EXITQUIT, "FInfoDlgProc", 0, "")
  539.    IF sz$ = "REACTIVATE" THEN
  540.       GOTO QUIT
  541.    ENDIF
  542.    UIPopALL
  543.    GOTO SEEYA
  544. ERR_UNEXPECTED:
  545.    sz$ = UIStartDlg (CUIDLL$, ERROR_UNEXPECTED, "FInfoDlgProc", 0, "")
  546.    IF sz$ = "REACTIVATE" THEN
  547.       GOTO ERR_UNEXPECTED
  548.    ENDIF
  549.    UIPop 1
  550.    GOTO FAILURE
  551. EXITFAIL:
  552.    sz$ = UIStartDlg (CUIDLL$, ExitCode%, "FInfoDlgProc", 0, "")
  553.    IF sz$ = "REACTIVATE" THEN
  554.       GOTO EXITFAIL
  555.    ENDIF
  556.    UIPop 1
  557.    GOTO FAILURE
  558. FAILURE:
  559.    sz$ = UIStartDlg (CUIDLL$, EXITFAILURE, "FInfoDlgProc", 0, "")
  560.    IF sz$ = "REACTIVATE" THEN
  561.       GOTO FAILURE
  562.    ENDIF
  563.    UIPopAll
  564.    GOTO SEEYA
  565. ERRORTRAP:
  566.    IF ERR = STFQUIT THEN
  567.       GOTO QUIT
  568.    ENDIF
  569.  
  570.    RESUME NEXT
  571.  
  572. SEEYA:
  573.    UIPopAll
  574.    IF (OLE_PROTECT% = 1) THEN
  575.  
  576.     '' Free all previously loaded libraries
  577.     FreeLibrary GetModuleHandle("compobj")
  578.     FreeLibrary GetModuleHandle("ole2")
  579.     FreeLibrary GetModuleHandle("ole2prox")
  580.     FreeLibrary GetModuleHandle("ole2conv")
  581.     FreeLibrary GetModuleHandle("storage")
  582.     FreeLibrary GetModuleHandle("ole2nls")
  583.     FreeLibrary GetModuleHandle("ole2disp")
  584.     FreeLibrary GetModuleHandle("typelib")
  585.    END IF
  586.  
  587. END
  588.  
  589.  
  590.  
  591. '' FROM HERE ON ARE FUNCTIONS IN THE ORIGINAL WING.MST FILE THAT THE WING SETUP USES
  592.  
  593. '**
  594. '** Purpose:
  595. '**     Appends a file name to the end of a directory path,
  596. '**     inserting a backslash character as needed.
  597. '** Arguments:
  598. '**     szDir$  - full directory path (with optional ending "\")
  599. '**     szFile$ - filename to append to directory
  600. '** Returns:
  601. '**     Resulting fully qualified path name.
  602. '*************************************************************************
  603. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  604.     IF szDir$ = "" THEN
  605.    MakePath = szFile$
  606.     ELSEIF szFile$ = "" THEN
  607.    MakePath = szDir$
  608.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  609.    MakePath = szDir$ + szFile$
  610.     ELSE
  611.    MakePath = szDir$ + "\" + szFile$
  612.     END IF
  613. END FUNCTION
  614.  
  615. SUB UpdateWinG32 (szOrig$) STATIC
  616.     '
  617.     ' Here we check the version ourselves of wing32.dll, since
  618.     ' we can't get version checking for Win32 apps from Win16
  619.     '
  620.     FileNew$ = MakePath(szOrig$, "wing32.dll")
  621.     FileOrig$ = MakePath(szOrig$, "wing32.xxx")
  622.     IF IsWin32FileNewer( FileOrig$, FileNew$ ) THEN
  623.       RemoveFile FileOrig$, cmoForce
  624.     ELSE
  625.       RemoveFile FileNew$, cmoForce    ' get rid of new file
  626.       RenameFilePlease FileOrig$,FileNew$ ' put back old file
  627.     END IF
  628. END SUB
  629.  
  630.  
  631. ''********************************************************************************
  632. ''              WIN32S install code starts here
  633. ''********************************************************************************
  634. FUNCTION CopyWin32sFiles STATIC AS INTEGER
  635. ''This first part is the same as the first part of AddWin32sFilesToFakeCopyList
  636. ''since it initializes thousands of vars and I didn't want to pass them all in
  637.     szOldVer$ ="1.00.000     "          '' Reserve space in string for version
  638. ''    WIN32ENABLED% = 0
  639. ''    OLEONLY% = 0
  640. ''    OLE2_16% = 0
  641. ''    OLE2AUTO_16% = 0
  642. ''    OLE16RUNAPP% = 0
  643. ''    OLE_PROTECT% = 0
  644. ''    OLE_OLEBOOT% = 0
  645.  
  646.  
  647.     WIN32SVER$ = MID$(GetSectionKeyVersion("WindowsSystem", "win32s16"), 1, 4)
  648.     VERNUM$ = MID$(WIN32SVER$, 1, 1) + MID$(WIN32SVER$, 3 , 2)
  649.  
  650.     DESTWIN$ = GetWindowsDir()
  651.     DEST32S$ = DESTWINSYS + "WIN32S\"
  652.  
  653.     IF OnWindowsNT() THEN
  654.         ExitCode% = EXITSUCCESS
  655.         GOTO ENDCOPY
  656.     ENDIF
  657.  
  658. ''Don't think we need this
  659. '''$IFDEF DEBUG
  660. ''    i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
  661. ''    WinDrive$ = MID$(GetWindowsDir, 1, 1)
  662. ''   IF IsDriveValid(WinDrive$) = 0 THEN
  663. ''        i% = DoMsgBox("La unidad de Windows no es correcta.", "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
  664. ''        GOTO QUIT
  665. ''    END IF
  666. '''$ENDIF ''DEBUG
  667.  
  668.     '' Get version of Win32s to be installed from version info in INF file
  669.     szNewVer$ = GetSectionKeyVersion("WindowsSystem", "win32s16")
  670.  
  671.     '' See if OLE is included.
  672.  
  673. ''    OLEINCLUDED% = DoesFileExist( GetSymbolValue("STF_SRCDIR") + "WIN32S\" + "OLE2THK.DL_", femExists )
  674.  
  675. ''    IF OLEINCLUDED% = 1 THEN
  676.     '' See whether one of the OLE 16 bit components is loaded.
  677. ''        IF GetModulehandle("compobj") <> 0 THEN
  678. ''            OLE16RUNAPP% = 1
  679. ''            GOTO GetOleVersion
  680. ''        END IF
  681. ''        IF GetModuleHandle("ole2") <> 0 THEN
  682. ''            OLE16RUNAPP% = 1
  683. ''            GOTO GetOleVersion
  684. ''        END IF
  685. ''        IF GetModuleHandle("ole2prox") <> 0 THEN
  686. ''            OLE16RUNAPP% = 1
  687. ''            GOTO GetOleVersion
  688. ''        END IF
  689. ''        IF GetModuleHandle("ole2conv") <> 0 THEN
  690. ''            OLE16RUNAPP% = 1
  691. ''            GOTO GetOleVersion
  692. ''        END IF
  693. ''        IF GetModuleHandle("storage") <> 0 THEN
  694. ''            OLE16RUNAPP% = 1
  695. ''            GOTO GetOleVersion
  696. ''        END IF
  697. ''        IF GetModuleHandle("ole2nls") <> 0 THEN
  698. ''            OLE16RUNAPP% = 1
  699. ''            GOTO GetOleVersion
  700. ''        END IF
  701. ''        IF GetModuleHandle("ole2disp") <> 0 THEN
  702. ''            OLE16RUNAPP% = 1
  703. ''            GOTO GetOleVersion
  704. ''        END IF
  705. ''        IF GetModuleHandle("typelib") <> 0 THEN
  706. ''            OLE16RUNAPP% = 1
  707. ''            GOTO GetOleVersion
  708. ''        END IF
  709. ''
  710. ''GetOleVersion:
  711. ''        szOleNewVer$ = GetSectionKeyVersion("OleWindowsSystemWin32s", "ole2thk")
  712. ''
  713. ''        '' Get version of currently installed OLE32 from version info of
  714. ''        '' ole2thk file
  715. ''        szOleOldVer$ = GetVersionOfFile( DESTWINSYS$ + "WIN32S\OLE2THK.DLL" )
  716. ''
  717. ''        szOle16OldVer$ = GetVersionOfFile( DESTWINSYS$ + "COMPOBJ.DLL" )
  718. ''        szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "compobj")
  719. ''        IF (szOle16NewVer$ > szOle16OldVer$) THEN
  720. ''            OLE2_16% = 1
  721. ''        END IF
  722. ''
  723. ''        szOle16OldVer$ = GetVersionOfFile( DESTWINSYS$ + "OLE2.DLL" )
  724. ''        szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "ole2")
  725. ''        IF (szOle16NewVer$ > szOle16OldVer$) THEN
  726. ''            OLE2_16% = 1
  727. ''        END IF
  728. ''
  729. ''        szOle16OldVer$ = GetVersionOfFile( DESTWINSYS$ + "OLE2PROX.DLL" )
  730. ''        szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "ole2prox")
  731. ''        IF (szOle16NewVer$ > szOle16OldVer$) THEN
  732. ''            OLE2_16% = 1
  733. ''        END IF
  734. ''
  735. ''        szOle16OldVer$ = GetVersionOfFile( DESTWINSYS$ + "STORAGE.DLL" )
  736. ''        szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "storage")
  737. ''        IF (szOle16NewVer$ > szOle16OldVer$) THEN
  738. ''            OLE2_16% = 1
  739. ''        END IF
  740. ''
  741. ''        szOle16OldVer$ = GetVersionOfFile( DESTWINSYS$ + "OLE2CONV.DLL" )
  742. ''        szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "ole2conv")
  743. ''        IF (szOle16NewVer$ > szOle16OldVer$) THEN
  744. ''            OLE2_16% = 1
  745. ''        END IF
  746.  ''
  747. ''        szOle16OldVer$ = GetVersionOfFile( DESTWINSYS$ + "OLE2NLS.DLL" )
  748. ''        szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "ole2nls")
  749. ''        IF (szOle16NewVer$ > szOle16OldVer$) THEN
  750. ''            OLE2AUTO_16% = 1
  751. ''        END IF
  752.  
  753. ''        szOle16OldVer$ = GetVersionOfFile( DESTWINSYS$ + "OLE2DISP.DLL" )
  754. ''        szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "ole2disp")
  755. ''        IF (szOle16NewVer$ > szOle16OldVer$) THEN
  756. ''            OLE2AUTO_16% = 1
  757. ''        END IF
  758.  
  759. ''        szOle16OldVer$ = GetVersionOfFile( DESTWINSYS$ + "TYPELIB.DLL" )
  760. ''        szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "typelib")
  761. ''        IF (szOle16NewVer$ > szOle16OldVer$) THEN
  762. ''            OLE2AUTO_16% = 1
  763. ''        END IF
  764.  
  765. ''    END IF
  766.  
  767. ''    OLE2_32% = OLEINCLUDED%
  768.  
  769.     '' Check if Win32s is partially installed'
  770.     sz$ = GetIniKeyString (DESTWINSYS$ + "WIN32S.INI", "Win32s", "Setup")
  771.     '' If WIN32S.INI specifies Win32s Setup=0, then force complete Win32s file overwrite
  772.     IF sz$ = "0" THEN
  773.     GOTO STARTWIN32SCOPY
  774.     END IF
  775.     '' If WIN32S.INI is missing, try and reinstall Win32s files/recreate WIN32S.INI
  776.     IF sz$ <> "1" THEN
  777.     GOTO STARTWIN32SCOPY
  778.     END IF
  779.  
  780.     '' If Win32s is already installed, get running version number
  781.     i% = DoesFileExist( DESTWINSYS$ + "W32SYS.DLL", femExists )
  782.     IF i% = 1 THEN
  783.     i% = IsWin32sLoaded( szOldVer$ )
  784.     ENDIF
  785.  
  786.     IF ERR <> 0 THEN
  787.     GOTO ERRNORMAL
  788.     END IF
  789.  
  790.     IF i% = 0 THEN
  791.     GOTO STARTWIN32SCOPY
  792.     END IF
  793.  
  794.     IF szNewVer$ > szOldVer$ THEN
  795.     GOTO STARTWIN32SCOPY
  796.     END IF
  797.  
  798.     IF OLEINCLUDED% = 1 THEN
  799.  
  800.     OLE2_32% = 0
  801.  
  802.     IF (szNewVer$ = szOldVer$) OR (szNewVer$ < szOldVer$) THEN
  803.         '' Compare OLE32 version and versions of each of OLE16 libraries.
  804.         sz$ = GetIniKeyString (DESTWINSYS$ + "WIN32S.INI", "OLE", "Setup")
  805.         '' If WIN32S.INI specifies OLE2 Setup=0, then force OLE2 file overwrite
  806.         IF ((sz$ <> "1") OR (szOleNewVer$ > szOleOldVer$)) THEN
  807.         OLEONLY% = 1
  808.         OLE2_32% = 1
  809.         GOTO STARTWIN32SCOPY
  810.         END IF
  811.  
  812.         IF OLE2_16% OR OLE2AUTO_16 THEN
  813.         OLEONLY% = 1
  814.         GOTO STARTWIN32SCOPY
  815.         END IF
  816.  
  817.     END IF
  818.  
  819.     END IF
  820.  
  821.     WIN32ENABLED% = 1
  822.  
  823. STARTWIN32SCOPY:
  824.     IF WIN32ENABLED% = 1 THEN
  825.     ExitCode% = EXITSUCCESS
  826.     GOTO ENDCOPY
  827.     END IF
  828.     IF OLEONLY% = 0 THEN
  829.     CreateIniKeyValue DESTWINSYS$ + "WIN32S.INI", "Win32s", "Setup", "0", cmoOverwrite
  830.     END IF
  831.     IF OLE2_32% = 1 THEN
  832.     CreateIniKeyValue DESTWINSYS$ + "WIN32S.INI", "OLE", "Setup", "0", cmoOverwrite
  833.     END IF
  834.  
  835.     IF ERR <> 0 THEN
  836.        GOTO ERRNORMAL
  837.     END IF
  838.  
  839.     '' Indicate Win32s install failure until all files known to be copied.
  840.     ExitCode% = EXITFAILURE
  841.     ERR = 0
  842.     CreateDir DEST32S$, cmoNone
  843.     InstallWin32S OLEONLY%, OLE2_32%, OLE2_16%, OLE2AUTO_16%, OLE16RUNAPP%
  844.     UpdateSystemIni
  845.     '' Terminate if unhandled fatal error
  846.     IF ERR <> 0 THEN
  847.        ExitCode% = EXITERROR
  848.        GOTO ENDCOPY
  849.     END IF
  850.  
  851.     IF OLEONLY% = 0 THEN
  852.     CreateIniKeyValue DESTWINSYS$ + "WIN32S.INI", "Win32s", "Setup", "1", cmoOverwrite
  853.     CreateIniKeyValue DESTWINSYS$ + "WIN32S.INI", "Win32s", "Version", szNewVer$, cmoOverwrite
  854.     CreateIniKeyValue DESTWINSYS$ + "WIN32S.INI", "Nls", "AnsiCP", "1252", cmoOverwrite
  855.     END IF
  856.     IF OLE2_32% = 1 THEN
  857.     CreateIniKeyValue DESTWINSYS$ + "WIN32S.INI", "OLE", "Setup", "1", cmoOverwrite
  858.     CreateIniKeyValue DESTWINSYS$ + "WIN32S.INI", "OLE", "Version", szOleNewVer, cmoOverwrite
  859.     END IF
  860.  
  861.     '' Indicate Win32s correctly copied and installed.
  862.     ExitCode% = EXITSUCCESS
  863.     GOTO ENDCOPY
  864. ERRNORMAL:
  865.     ExitCode% = EXITFAILURE
  866. ENDCOPY:
  867.     CopyWin32sFiles = ExitCode%
  868. END FUNCTION
  869.  
  870.  
  871. FUNCTION AddWin32sToFakeCopyList STATIC AS INTEGER
  872.     szOldVer$ ="1.00.000     "          '' Reserve space in string for version
  873.     WIN32ENABLED% = 0
  874.     OLEONLY% = 0
  875.     OLE2_16% = 0
  876.     OLE2AUTO_16% = 0
  877.     OLE16RUNAPP% = 0
  878.     OLE_PROTECT% = 0
  879.     OLE_OLEBOOT% = 0
  880.  
  881.     ERR = 0
  882.     WIN32SVER$ = MID$(GetSectionKeyVersion("WindowsSystem", "win32s16"), 1, 4)
  883.     VERNUM$ = MID$(WIN32SVER$, 1, 1) + MID$(WIN32SVER$, 3 , 2)
  884.  
  885.     DESTWIN$ = GetWindowsDir()
  886.     DEST32S$ = DESTWINSYS + "WIN32S\"
  887. ''Don't think we need this
  888. '''$IFDEF DEBUG
  889. ''    i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
  890. ''    WinDrive$ = MID$(GetWindowsDir, 1, 1)
  891. ''   IF IsDriveValid(WinDrive$) = 0 THEN
  892. ''        i% = DoMsgBox("La unidad de Windows no es correcta.", "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
  893. ''        GOTO QUIT
  894. ''    END IF
  895. '''$ENDIF ''DEBUG
  896. CHECKWIN32S:
  897.     ''standard checks were done in main INIT
  898.     IF OnWindowsNT() THEN
  899.         ExitCode% = EXITSUCCESS
  900.         GOTO ENDFAKE
  901.     ENDIF
  902.  
  903.     IF IsRunningApp() <> 0 THEN
  904.     i% = DoMsgBox("Salga de los otros programas y haga clic en OK.", TITLE, MB_ICONHAND + MB_OKCANCEL)
  905.     IF i% = IDOK THEN
  906.         GOTO CHECKWIN32S
  907.     ELSE
  908.         GOTO ERRNORMAL
  909.     END IF
  910.     END IF
  911.  
  912.     IF SHAREMISSING% = 0 and ShareEnabled() = 0 THEN
  913.         SHAREMISSING% = 1
  914.     END IF
  915.     '' Get version of Win32s to be installed from version info in INF file
  916.     szNewVer$ = GetSectionKeyVersion("WindowsSystem", "win32s16")
  917.  
  918.     '' See if OLE is included.
  919. ''I don't think any of this OLE stuff will ever happen since we're not shipping
  920. '' OLE2THK.DLL, just the win32s stuff
  921.     OLEINCLUDED% = DoesFileExist( GetSymbolValue("STF_SRCDIR") + "WIN32S\" + "OLE2THK.DL_", femExists )
  922.  
  923.     IF OLEINCLUDED% = 1 THEN
  924.     '' See whether one of the OLE 16 bit components is loaded.
  925.     IF GetModulehandle("compobj") <> 0 THEN
  926.         OLE16RUNAPP% = 1
  927.         GOTO GetOleVersion
  928.     END IF
  929.     IF GetModuleHandle("ole2") <> 0 THEN
  930.         OLE16RUNAPP% = 1
  931.         GOTO GetOleVersion
  932.     END IF
  933.     IF GetModuleHandle("ole2prox") <> 0 THEN
  934.         OLE16RUNAPP% = 1
  935.         GOTO GetOleVersion
  936.     END IF
  937.     IF GetModuleHandle("ole2conv") <> 0 THEN
  938.         OLE16RUNAPP% = 1
  939.         GOTO GetOleVersion
  940.     END IF
  941.     IF GetModuleHandle("storage") <> 0 THEN
  942.         OLE16RUNAPP% = 1
  943.         GOTO GetOleVersion
  944.     END IF
  945.     IF GetModuleHandle("ole2nls") <> 0 THEN
  946.         OLE16RUNAPP% = 1
  947.         GOTO GetOleVersion
  948.     END IF
  949.     IF GetModuleHandle("ole2disp") <> 0 THEN
  950.         OLE16RUNAPP% = 1
  951.         GOTO GetOleVersion
  952.     END IF
  953.     IF GetModuleHandle("typelib") <> 0 THEN
  954.         OLE16RUNAPP% = 1
  955.         GOTO GetOleVersion
  956.     END IF
  957.  
  958. GetOleVersion:
  959.     szOleNewVer$ = GetSectionKeyVersion("OleWindowsSystemWin32s", "ole2thk")
  960.  
  961.     '' Get version of currently installed OLE32 from version info of
  962.     '' ole2thk file
  963.     szOleOldVer$ = GetVersionOfFile( DESTWINSYS$ + "WIN32S\OLE2THK.DLL" )
  964.  
  965.     szOle16OldVer$ = GetVersionOfFile( DESTWINSYS$ + "COMPOBJ.DLL" )
  966.     szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "compobj")
  967.     IF (szOle16NewVer$ > szOle16OldVer$) THEN
  968.         OLE2_16% = 1
  969.     END IF
  970.  
  971.     szOle16OldVer$ = GetVersionOfFile( DESTWINSYS$ + "OLE2.DLL" )
  972.     szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "ole2")
  973.     IF (szOle16NewVer$ > szOle16OldVer$) THEN
  974.         OLE2_16% = 1
  975.     END IF
  976.  
  977.     szOle16OldVer$ = GetVersionOfFile( DESTWINSYS$ + "OLE2PROX.DLL" )
  978.     szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "ole2prox")
  979.     IF (szOle16NewVer$ > szOle16OldVer$) THEN
  980.         OLE2_16% = 1
  981.     END IF
  982.  
  983.     szOle16OldVer$ = GetVersionOfFile( DESTWINSYS$ + "STORAGE.DLL" )
  984.     szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "storage")
  985.     IF (szOle16NewVer$ > szOle16OldVer$) THEN
  986.         OLE2_16% = 1
  987.     END IF
  988.  
  989.     szOle16OldVer$ = GetVersionOfFile( DESTWINSYS$ + "OLE2CONV.DLL" )
  990.     szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "ole2conv")
  991.     IF (szOle16NewVer$ > szOle16OldVer$) THEN
  992.         OLE2_16% = 1
  993.     END IF
  994.  
  995.     szOle16OldVer$ = GetVersionOfFile( DESTWINSYS$ + "OLE2NLS.DLL" )
  996.     szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "ole2nls")
  997.     IF (szOle16NewVer$ > szOle16OldVer$) THEN
  998.         OLE2AUTO_16% = 1
  999.     END IF
  1000.  
  1001.     szOle16OldVer$ = GetVersionOfFile( DESTWINSYS$ + "OLE2DISP.DLL" )
  1002.     szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "ole2disp")
  1003.     IF (szOle16NewVer$ > szOle16OldVer$) THEN
  1004.         OLE2AUTO_16% = 1
  1005.     END IF
  1006.  
  1007.     szOle16OldVer$ = GetVersionOfFile( DESTWINSYS$ + "TYPELIB.DLL" )
  1008.     szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "typelib")
  1009.     IF (szOle16NewVer$ > szOle16OldVer$) THEN
  1010.         OLE2AUTO_16% = 1
  1011.     END IF
  1012.  
  1013.     END IF
  1014. ''End of OLE stuff that I think will never happen. SD
  1015.     OLE2_32% = OLEINCLUDED%
  1016.  
  1017.     '' Check if Win32s is partially installed
  1018.     sz$ = GetIniKeyString (DESTWINSYS$ + "WIN32S.INI", "Win32s", "Setup")
  1019.     '' If WIN32S.INI specifies Win32s Setup=0, then force complete Win32s file overwrite
  1020.     IF sz$ = "0" THEN
  1021.     GOTO ADDFILES
  1022.     END IF
  1023.     '' If WIN32S.INI is missing, try and reinstall Win32s files/recreate WIN32S.INI
  1024.     IF sz$ <> "1" THEN
  1025.     GOTO ADDFILES
  1026.     END IF
  1027.  
  1028.     '' If Win32s is already installed, get running version number
  1029.     i% = DoesFileExist( DESTWINSYS$ + "W32SYS.DLL", femExists )
  1030.     IF i% = 1 THEN
  1031.     i% = IsWin32sLoaded( szOldVer$ )
  1032.     ENDIF
  1033.  
  1034.     IF i% = 0 THEN
  1035.     GOTO ADDFILES
  1036.     END IF
  1037.  
  1038.     IF szNewVer$ > szOldVer$ THEN
  1039.     GOTO ADDFILES
  1040.     END IF
  1041.  
  1042.     IF OLEINCLUDED% = 1 THEN
  1043.  
  1044.     OLE2_32% = 0
  1045.  
  1046.     IF (szNewVer$ = szOldVer$) OR (szNewVer$ < szOldVer$) THEN
  1047.         '' Compare OLE32 version and versions of each of OLE16 libraries.
  1048.         sz$ = GetIniKeyString (DESTWINSYS$ + "WIN32S.INI", "OLE", "Setup")
  1049.         '' If WIN32S.INI specifies OLE2 Setup=0, then force OLE2 file overwrite
  1050.         IF ((sz$ <> "1") OR (szOleNewVer$ > szOleOldVer$)) THEN
  1051.         OLEONLY% = 1
  1052.         OLE2_32% = 1
  1053.         GOTO ADDFILES
  1054.         END IF
  1055.  
  1056.         IF OLE2_16% OR OLE2AUTO_16 THEN
  1057.         OLEONLY% = 1
  1058.         GOTO ADDFILES
  1059.         END IF
  1060.  
  1061.     END IF
  1062.  
  1063.     END IF
  1064.  
  1065.     WIN32ENABLED% = 1
  1066.     ExitCode% = EXITSUCCESS
  1067.     GOTO ENDFAKE
  1068. ADDFILES:
  1069.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  1070.  
  1071.     '' Use file layout sections that specify OLDER file version/time check
  1072.     IF OLEONLY% = 0 THEN
  1073.     AddSectionFilesToCopyList "WindowsSystem", SrcDir$ + "WIN32S\", DESTWINSYS$
  1074.     AddSectionFilesToCopyList "WindowsSystemWin32s", SrcDir$ + "WIN32S\", DESTWINSYS$ + "WIN32S\"
  1075.     '' Add obsolete files to be removed
  1076.     AddSectionFilesToCopyList "Win32sSystemObsoleteFiles", SrcDir$ + "WIN32S", DESTWINSYS$ + "WIN32S\"
  1077.     END IF
  1078.  
  1079.     OLE_PROTECT% = 0
  1080.     OLEINCLUDED% = DoesFileExist( GetSymbolValue("STF_SRCDIR") + "WIN32S\" + "OLE2THK.DL_", femExists )
  1081. ''This OLE stuff should never happen. SD
  1082.     if OLEINCLUDED% = 1 THEN
  1083.     IF (OLE2_16% = 1) OR (OLE2AUTO_16% = 1) THEN
  1084.         AddSectionFilesToCopyList "OleWindowsSystem", SrcDir$ + "WIN32S\", DESTWINSYS$
  1085.     END IF
  1086.     IF OLE2_32% = 1 THEN
  1087.         AddSectionFilesToCopyList "OleWindowsSystemWin32s", SrcDir$ + "WIN32S\", DESTWINSYS$ + "WIN32S\"
  1088.     END IF
  1089.     IF (OLE2_16% = 1) OR (OLE2_32% = 1) OR (OLE2AUTO_16% = 1) THEN
  1090.         AddSectionFilesToCopyList "Ole2RegWindowsSystem", SrcDir$ + "WIN32S\", DESTWINSYS$
  1091.     END IF
  1092.     IF (OLE2AUTO_16% = 1) THEN
  1093.         AddSectionFilesToCopyList "StdoleWindowsSystem", SrcDir$ + "WIN32S\", DESTWINSYS$
  1094.     END IF
  1095.     END IF
  1096.     IF ERR <> 0 THEN
  1097.     GOTO ERRNORMAL
  1098.     END IF
  1099.     ExitCode% = EXITSUCCESS
  1100.     GOTO ENDFAKE
  1101. ERRNORMAL:
  1102.     ExitCode% = EXITFAILURE
  1103. ENDFAKE:
  1104.     AddWin32sToFakeCopyList = ExitCode%
  1105. END FUNCTION
  1106.  
  1107.  
  1108. '**
  1109. '** Purpose:
  1110. '**     Builds the copy list and performs all installation operations.
  1111. '** Arguments:
  1112. '**     none.
  1113. '** Returns:
  1114. '**     none.
  1115. '*************************************************************************
  1116. SUB InstallWin32s(OLEONLY%, OLE2_32%, OLE2_16%, OLE2AUTO_16%, OLE16RUNAPP%) STATIC
  1117.  
  1118.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  1119.  
  1120.     '' Use file layout sections that specify OLDER file version/time check
  1121.     IF OLEONLY% = 0 THEN
  1122.     AddSectionFilesToCopyList "WindowsSystem", SrcDir$ + "WIN32S\", DESTWINSYS$
  1123.     AddSectionFilesToCopyList "WindowsSystemWin32s", SrcDir$ + "WIN32S\", DESTWINSYS$ + "WIN32S\"
  1124.     '' Add obsolete files to be removed
  1125.     AddSectionFilesToCopyList "Win32sSystemObsoleteFiles", SrcDir$ + "WIN32S\", DESTWINSYS$ + "WIN32S\"
  1126.     END IF
  1127.  
  1128.     OLE_PROTECT% = 0
  1129.     OLEINCLUDED% = DoesFileExist( GetSymbolValue("STF_SRCDIR") + "WIN32S\" + "OLE2THK.DL_", femExists )
  1130.  
  1131.     if OLEINCLUDED% = 1 THEN
  1132.     IF (OLE2_16% = 1) OR (OLE2AUTO_16% = 1) THEN
  1133.         IF OLE16RUNAPP% = 1 THEN
  1134.         '' Force all OLE2 DLLS to be copied during reboot.
  1135.         i% = SetErrorMode(-32768)
  1136.         i% = LoadLibrary(DESTWINSYS$ + "compobj.dll")
  1137.         i% = LoadLibrary(DESTWINSYS$ + "ole2.dll")
  1138.         i% = LoadLibrary(DESTWINSYS$ + "ole2prox.dll")
  1139.         i% = LoadLibrary(DESTWINSYS$ + "ole2conv.dll")
  1140.         i% = LoadLibrary(DESTWINSYS$ + "storage.dll")
  1141.         i% = LoadLibrary(DESTWINSYS$ + "ole2nls.dll")
  1142.         i% = LoadLibrary(DESTWINSYS$ + "ole2disp.dll")
  1143.         i% = LoadLibrary(DESTWINSYS$ + "typelib.dll")
  1144.         OLE_PROTECT% = 1
  1145.         END IF
  1146.         AddSectionFilesToCopyList "OleWindowsSystem", SrcDir$ + "WIN32S\", DESTWINSYS$
  1147.     END IF
  1148.     IF OLE2_32% = 1 THEN
  1149.         AddSectionFilesToCopyList "OleWindowsSystemWin32s", SrcDir$ + "WIN32S\", DESTWINSYS$ + "WIN32S\"
  1150.     END IF
  1151.     IF (OLE2_16% = 1) OR (OLE2_32% = 1) OR (OLE2AUTO_16% = 1) THEN
  1152.         AddSectionFilesToCopyList "Ole2RegWindowsSystem", SrcDir$ + "WIN32S\", DESTWINSYS$
  1153.     END IF
  1154.     IF (OLE2AUTO_16% = 1) THEN
  1155.         AddSectionFilesToCopyList "StdoleWindowsSystem", SrcDir$ + "WIN32S\", DESTWINSYS$
  1156.         IF (OLE16RUNAPP and DoesFileExist(DESTWINSYS$ + "WIN32S\" + "stdole.tlb", femExists) ) THEN
  1157.         ' copy stdole.tlb -> tempfile1
  1158.         stdole1$ = DESTWINSYS$ + GetTempFileAt(DESTWINSYS$, "STD")
  1159.         CopyFile DESTWINSYS$+"STDOLE.TLB", stdole1$, cmoOverwrit, 0
  1160.         OLE_OLEBOOT% = 1
  1161.         ENDIF
  1162.     END IF
  1163.     END IF
  1164.  
  1165.     CopyFilesInCopyList
  1166.  
  1167.     IF (OLEINCLUDED% = 1) THEN
  1168.     RecoverFromCopy DESTWINSYS$ + "compobj.dll"
  1169.     RecoverFromCopy DESTWINSYS$ + "ole2.dll"
  1170.     RecoverFromCopy DESTWINSYS$ + "ole2prox.dll"
  1171.     RecoverFromCopy DESTWINSYS$ + "ole2conv.dll"
  1172.     RecoverFromCopy DESTWINSYS$ + "storage.dll"
  1173.     RecoverFromCopy DESTWINSYS$ + "ole2nls.dll"
  1174.     RecoverFromCopy DESTWINSYS$ + "ole2disp.dll"
  1175.     RecoverFromCopy DESTWINSYS$ + "typelib.dll"
  1176.     END IF
  1177.  
  1178.     IF (OLE_PROTECT% = 1) THEN
  1179.     '' Free all previously loaded libraries
  1180.     FreeLibrary GetModuleHandle("compobj")
  1181.     FreeLibrary GetModuleHandle("ole2")
  1182.     FreeLibrary GetModuleHandle("ole2prox")
  1183.     FreeLibrary GetModuleHandle("ole2conv")
  1184.     FreeLibrary GetModuleHandle("storage")
  1185.     FreeLibrary GetModuleHandle("ole2nls")
  1186.     FreeLibrary GetModuleHandle("ole2disp")
  1187.     FreeLibrary GetModuleHandle("typelib")
  1188.     OLE_PROTECT% = 0
  1189.     END IF
  1190.  
  1191.     IF (OLE_OLEBOOT% = 1) THEN
  1192.         'rename new stdole.tlb -> tempfile2
  1193.         stdole2$ = GetTempFileAt(DESTWINSYS$, "STD")
  1194.         RemoveFile DESTWINSYS$+stdole2$, cmoForce
  1195.         RenameFile DESTWINSYS$+"STDOLE.TLB" , stdole2$
  1196.         'rename tempfile1 -> stdole.tlb
  1197.         RenameFile stdole1$, "STDOLE.TLB"
  1198.         'write to _mssetup.bat: rename tempfile2 to stdole.tlb
  1199.         WriteLine DESTWIN$+"_MSSETUP.BAT", ""
  1200.         WriteLine DESTWIN$+"_MSSETUP.BAT", "DEL "+DESTWINSYS$+"STDOLE.TLB"
  1201.         WriteLine DESTWIN$+"_MSSETUP.BAT", "REN "+DESTWINSYS$+stdole2$+" STDOLE.TLB"
  1202.     ENDIF
  1203.  
  1204.     IF OLEINCLUDED% AND (OLE2_16% OR OLE2_32% OR OLE2AUTO_16%) THEN
  1205.     IF OLE16RUNAPP% THEN
  1206.         reg1$ = DESTWIN$ + GetTempFileAt(DESTWIN$, "REG")
  1207.         CopyFile DESTWIN$+"REG.DAT", reg1$, cmoOverwrit, 0
  1208.     ENDIF
  1209.  
  1210.     RUN "regedit /s " + DESTWINSYS$ + "ole2.reg"
  1211.  
  1212.     IF OLE16RUNAPP% THEN
  1213.         reg2$ = GetTempFileAt(DESTWIN$, "REG")
  1214.         RemoveFile DESTWIN$ + reg2$, cmoForce
  1215.         RenameFile DESTWIN$ + "REG.DAT" , reg2$
  1216.         'rename tempfile1 -> reg.dat
  1217.         RenameFile reg1$, "REG.DAT"
  1218.         'write to _mssetup.bat: rename tempfile2 to reg.dat
  1219.         WriteLine DESTWIN$+"_MSSETUP.BAT", ""
  1220.         WriteLine DESTWIN$+"_MSSETUP.BAT", "DEL "+DESTWIN$+"REG.DAT"
  1221.         WriteLine DESTWIN$+"_MSSETUP.BAT", "REN "+DESTWIN$ + reg2$+" REG.DAT"
  1222.         OLE_OLEBOOT% = 1
  1223.     ENDIF
  1224.     END IF
  1225. END SUB
  1226.  
  1227. SUB UpdateSystemIni STATIC
  1228.     VxDPath$ = DEST32S$ + "W32S.386"
  1229.     SystemIniPath$ = GetWindowsDir()
  1230.  
  1231.     t% = MakeSystemIni(SystemIniPath$, VxdPath$)
  1232. END SUB
  1233.  
  1234. FUNCTION RebootSystem(ONLY_IF_RESTART_NOT_EMPTY%) STATIC AS INTEGER
  1235. '   Check if any files were locked during install.  If the RestartList
  1236. '   is not empty, ExitExecRestart() will restart Windows, cleanup setup
  1237. '   files, and copy over locked files before Windows restarts.
  1238.     i% = RestartListEmpty()
  1239.     CUIDLL$ = "MSCUISTF.DLL"
  1240.     IF ((i% = 0) or (not (ONLY_IF_RESTART_NOT_EMPTY% = 1))) THEN
  1241. RESTART:
  1242.     sz$ = UIStartDlg(CUIDLL$, RESTART, "FInfo0DlgProc", 0, "")
  1243.     IF sz$ = "REACTIVATE" THEN
  1244.         GOTO RESTART
  1245.     END IF
  1246.     END IF
  1247.  
  1248.     IF i% = 0 THEN
  1249. '      ExitExecRestart() only returns if applications refuse to be shutdown.
  1250. '      Win32s is installed but will not operate until Windows is restarted
  1251. '      and the Win32s VxD is loaded.
  1252.        i% = ExitExecRestart()
  1253.        RebootSystem = 0
  1254.     ELSE
  1255. '      If the RestartList list is empty, it is necessary to restart windows
  1256. '      directly.  The MSSETUP program creates _MSRSTRT.EXE and _MSSETUP.BAT
  1257. '      in the restart directory.  This program should be exec'd to handle
  1258. '      proper MSSETUP cleanup (temp files) and restart Windows.
  1259.        IF (ONLY_IF_RESTART_NOT_EMPTY% = 1) THEN
  1260.        RebootSystem = 1
  1261.        ELSE
  1262.        i% = ExitWindowsExec( GetWindowsDir() + "_MSRSTRT.EXE", "_MSSETUP.BAT" )
  1263.        RebootSystem = 0
  1264.        END IF
  1265.     ENDIF
  1266. ENDREBOOTSYSTEM:
  1267. END FUNCTION
  1268.  
  1269.  
  1270.  
  1271. FUNCTION GetTempFileAt(szDir$, szPrefix$) STATIC AS STRING
  1272.     szCurDir$ = CURDIR$
  1273.     CHDIR szDir$ + "."
  1274.     szTempFile$ = STRING$(144, "E")
  1275.     i% = GetTempFileName(TF_FORCEDRIVE, szPrefix$,0, szTempFile$)
  1276.     CHDIR szCurDir$
  1277.     GetTempFileAt = MID$(szTempFile$,3)
  1278. END FUNCTION
  1279.  
  1280. SUB RecoverFromCopy(szFileName$) STATIC
  1281.     IF DoesFileExist(szFileName$, femExist) = 0 THEN
  1282.     szBackFile$ = MID$(szFileName$, 1, LEN(szFileName$)-3) + VERNUM$
  1283.     IF DoesfileExist(szBackFile$, femExist) = 0 THEN
  1284.         i% = DoMsgBox("ERROR: Could not find backup file "+szBackfile$, "Setup Error", MB_ICONEXLAMATION + MB_OK)
  1285.     ELSE
  1286.         CopyFile szBackFile$, szFileName$, cmoTimeStamp, 0
  1287.     END IF
  1288.     END IF
  1289. END SUB
  1290.