home *** CD-ROM | disk | FTP | other *** search
/ PC/CD Review 59 / PCR59.iso / disk1 / install.mst < prev    next >
Encoding:
Text File  |  1996-02-26  |  11.4 KB  |  362 lines

  1. '**************************************************************************
  2. '*                       MSSetup for Updata 'Teleshares
  3. '**************************************************************************
  4.  
  5. '$DEFINE DEBUG  ''Define for script development/debugging
  6.  
  7. '$INCLUDE 'setupapi.inc'
  8. '$INCLUDE 'msdetect.inc'
  9.  
  10. ''Dialog ID's
  11. CONST MB_OKCANCEL       = 1
  12. CONST MB_YESNO          = 4
  13. CONST MB_ICONQUESTION = 32
  14. CONST WELCOME       = 100
  15. CONST ASKQUIT       = 200
  16. CONST DESTPATH      = 300
  17. CONST EXITFAILURE   = 400
  18. CONST EXITQUIT      = 600
  19. CONST EXITSUCCESS   = 700
  20. CONST OPTIONS       = 800
  21. CONST APPHELP       = 900
  22. CONST BADPATH       = 6400
  23. CONST MODELESS      = 5000
  24. CONST CDGETNAMEORG  = 7500
  25. CONST MODELESS_1    = 10000
  26. CONST MODELESS_2    = 10001
  27. CONST MODELESS_3    = 10002
  28. CONST MODELESS_4    = 10003
  29.  
  30. ''Bitmap ID
  31. CONST LOGO = 1
  32.  
  33. GLOBAL DEST$        ''Default destination directory.
  34. GLOBAL OPTCUR$      ''Option selection from option dialog.
  35. GLOBAL NameOut$         ''Name entered
  36. GLOBAL OrgOut$          ''Organisation entered
  37. GLOBAL nIniFlag%        ''1 if ini file is one system
  38.  
  39. DECLARE SUB Install
  40. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  41. DECLARE FUNCTION CreateWindow LIB "user" (szClassName$,szWindowName$,dwStyle%,nX%,nY%,nWidth%,nHeight%,hwndParent%,hMenu%,hInst%,szPnt%) AS INTEGER
  42. DECLARE FUNCTION ShowWindow LIB "user" (hWnd%,nCmdShow%) AS INTEGER
  43. DECLARE FUNCTION SetWindowLong LIB "user" (hWnd%,nOffset%,nVal%) AS INTEGER
  44. DECLARE FUNCTION UserInput LIB "s_optns.dll" (hWnd%, szString3$ ) AS INTEGER
  45. DECLARE FUNCTION EditSystemFiles LIB "s_edsys.dll" (hWnd%) AS INTEGER
  46. DECLARE FUNCTION CheckIniEntry LIB "s_edsys.dll" (hWnd%, szString4$, szString5$) AS INTEGER
  47. DECLARE FUNCTION WerePriceFilesChosen LIB "s_edsys.dll" ( hWnd% ) AS INTEGER
  48. DECLARE FUNCTION UnZipFiles LIB "s_edsys.dll" ( hWnd%, szString6$ ) AS INTEGER
  49. DECLARE FUNCTION SetupMicrotextHardware LIB "mtunedll.dll" (hWnd%) AS INTEGER
  50. DECLARE FUNCTION IsStringInString LIB "mscuistf.dll" (szString1$ , szString2$) AS INTEGER
  51. DECLARE FUNCTION ChangeDir LIB "mscuistf.dll" (szDir$) AS INTEGER
  52. DECLARE FUNCTION WinExec LIB "kernel" (lpCmdLine$, nCmdShow% ) AS INTEGER
  53. DECLARE SUB CreateBackDrop
  54. DECLARE SUB SetParameters
  55.  
  56.  
  57. INIT:
  58.     CUIDLL$ = "mscuistf.dll"           ''Custom user interface dll
  59.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  60.  
  61.     SetBitmap CUIDLL$, LOGO
  62.     SetTitle "TeleShares v2.1 Setup"
  63.  
  64.     CreateBackDrop
  65.  
  66.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  67.     IF szInf$ = "" THEN
  68.         szInf$ = GetSymbolValue("STF_CWDDIR") + "FILES.INF"
  69.     END IF
  70.   
  71.     DEST$ = "C:\UPDATA"
  72.  
  73.     i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
  74.     WinDrive$ = MID$(GetWindowsDir, 1, 1)
  75.     IF IsDriveValid(WinDrive$) = 0 THEN
  76.         i% = DoMsgBox("Windows drive ('"+WinDrive$+"') is not a valid drive.", "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
  77.         GOTO QUIT
  78.     END IF
  79.  
  80.  
  81. GETPATH:
  82.     SetSymbolValue "EditTextIn", DEST$
  83.     SetSymbolValue "EditFocus", "END"
  84. GETPATHL1:
  85.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  86.     DEST$ = GetSymbolValue("EditTextOut")
  87.  
  88.     IF sz$ = "CONTINUE" THEN
  89.         IF IsDirWritable(DEST$) = 0 THEN
  90.             GOSUB BADPATH
  91.         GOTO GETPATHL1
  92.         END IF
  93.         UIPop 1
  94.     ELSEIF sz$ = "REACTIVATE" THEN
  95.             GOTO GETPATHL1
  96.     ELSE
  97.             UIPop 1
  98.             GOSUB ASKQUIT
  99.             GOTO GETPATH
  100.     END IF
  101.  
  102.     WinDrive$ = GetWindowsDir()
  103.     WinFile$ = WinDrive$ + "UPDATA.INI"
  104.     nIniFlag% = DoesFileExist (WinFile$,femExists )
  105.     if nIniFlag% = 0 Then
  106.     sz$ = UIStartDlg(CUIDLL$,CDGETNAMEORG,"FNameOrgDlgProc",APPHELP,HELPPROC$)
  107.     NameOut$=GetSymbolValue("NameOut")
  108.     OrgOut$=GetSymbolValue("OrgOut")
  109.     UIPop 1
  110.     end if
  111.  
  112.     IF sz$ = "CONTINUE" THEN
  113.   
  114.     ReadInfFile szInf$ 
  115.  
  116.         Install
  117.         ClearBillboardList
  118.     ELSE
  119.         UIPop 1
  120.         GOSUB ASKQUIT
  121.         GOTO GETPATH
  122.     END IF
  123.  
  124. QUIT:
  125.  
  126.     SetSymbolValue "Path", DEST$
  127.     ON ERROR GOTO ERRQUIT
  128.  
  129.     IF ERR = 0 THEN
  130.         dlg% = EXITSUCCESS
  131.     ELSEIF ERR = STFQUIT THEN
  132.             dlg% = EXITQUIT
  133.     ELSE
  134.             dlg% = EXITFAILURE
  135.     END IF
  136. QUITL1:
  137.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  138.     IF sz$ = "REACTIVATE" THEN
  139.         GOTO QUITL1
  140.     END IF
  141.     UIPop 1
  142.  
  143.     END
  144.  
  145. ERRQUIT:
  146.     i% = DoMsgBox("Setup sources were corrupted, call 0181-874-4747!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  147.     END
  148.  
  149.  
  150.  
  151. BADPATH:
  152.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  153.     IF sz$ = "REACTIVATE" THEN
  154.         GOTO BADPATH
  155.     END IF
  156.     UIPop 1
  157.     RETURN
  158.  
  159. ASKQUIT:
  160.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  161.  
  162.     IF sz$ = "EXIT" THEN
  163.         UIPopAll
  164.         ERROR STFQUIT
  165.     ELSEIF sz$ = "REACTIVATE" THEN
  166.             GOTO ASKQUIT
  167.     ELSE
  168.             UIPop 1
  169.     END IF
  170.     RETURN
  171.  
  172.  
  173.  
  174. SUB SetParameters STATIC
  175.  
  176.     drive$ = MID$(DEST$, 1, 1)
  177.     SizeofFreeDisk& = GetFreeSpaceForDrive(drive$)
  178.     IF SizeofFreeDisk& < 3072000 THEN
  179.     StringOne$ =  "You need at least 3MB of free space on your hard disk to install the Updata for Windows Files"
  180.     StringTwo$ =  ""
  181.     MessageString$ = StringOne$ + StringTwo$
  182.     i% = DoMsgBox( MessageString$, "WARNING", MB_TASKMODAL+MB_ICONHAND+MB_OK)
  183.     WriteToLogFile "Not enough space to install Price files"
  184.     END IF
  185.     IF SizeofFreeDisk& > 3072000 THEN
  186.     WriteToLogFile "Enough space to install Price files"
  187.     END IF
  188.  
  189.     WinMajorVer% = GetWindowsMajorVersion()
  190.     WinMinorVer% = GetWindowsMajorVersion()
  191.     IF WinMajorVer% = 3 THEN
  192.         IF WinMinorVer% > 0 THEN
  193.             WriteToLogFile "Windows Version 3.1 detected."
  194.         END IF
  195.     END IF
  196.     IF WinMajorVer% = 3 THEN
  197.         IF WinMinorVer% < 1 THEN
  198.             i% = DoMsgBox("This Program requires Windows 3.1 or greater.", "ERROR", MB_TASKMODAL+MB_ICONHAND+MB_OK)
  199.             WriteToLogFile "Windows 3.0 detected."
  200.         END IF
  201.     END IF
  202.  
  203.  
  204.   
  205.     WinDrive$ = GetWindowsDir()
  206.     SourceDrive$ = MakePath(DEST$, "TELETEXT.FON")
  207.     WinFile$ = WinDrive$ + "TELETEXT.FON"
  208.     CopyFile SourceDrive$, WinFile$, cmoNone, 0
  209.     WriteToLogFile "Teletext font file copied OK."
  210.  
  211.     IF DoesIniKeyExist("WIN.INI", "fonts", "Teletext") = 0 THEN
  212.     CreateIniKeyValue "WIN.INI", "fonts", "Teletext", "TELETEXT.FON", cmoNone
  213.     WriteToLogFile "Teletext fonts installed OK"
  214.     END IF
  215.  
  216.  
  217.  
  218.     SourceDrive$ = MakePath(DEST$, "UPDATA.INI")
  219.     WinFile$ = WinDrive$ + "UPDATA.INI"
  220.  
  221.     if nIniFlag% = 0 Then
  222.     CopyFile SourceDrive$, WinFile$, cmoNone, 0
  223.     WriteToLogFile "Updata.INI file copied OK."
  224.     CreateIniKeyValue WinFile$,"LICENCE","NAME",NameOut$,cmoOverwrite
  225.     CreateIniKeyValue WinFile$,"LICENCE","ORG",OrgOut$,cmoOverwrite
  226.     else
  227.         WriteToLogFile "Updata.INI file already exists."
  228.     end if
  229.  
  230.     CreateIniKeyValue WinFile$,"PATHS","UPDATA",Dest$,cmoOverwrite
  231.  
  232.     Path$ = GetEnvVariableValue ( "PATH" )
  233.     i% = IsStringInString ( DEST$, Path$ )
  234.     ''IF i% = 0 THEN
  235.      ''   StringThree$ = "Your Autoexec.bat file needs to be modified, "
  236.      ''   StringFour$  = "by placing the Updata directory on the path. "
  237.      ''   StringFive$  = "Do you want setup to modify the file for you?"
  238.      ''   Message$     = StringThree$ + StringFour$ + StringFive$
  239.      ''   i% = DoMsgBox( Message$, "MESSAGE", MB_ICONQUESTION + MB_YESNO)
  240.       ''  IF i% = 6 THEN
  241.       ''      RemoveFile "C:\AUTOEXEC.UDT",cmoNone
  242.       ''      RenameFile "C:\AUTOEXEC.BAT","AUTOEXEC.UDT"
  243.       ''      PrependToPath "C:\AUTOEXEC.UDT","C:\AUTOEXEC.BAT",DEST$,cmoNone
  244.       ''  ENDIF
  245.    '' ENDIF
  246.  
  247.     StringThree$ = ""
  248.     StringFour$  = "If you have not tuned your teletext card we suggest that you tune it. "
  249.     StringFive$  = "Do you wish to tune your card now ?         "
  250.     Message$     = StringThree$ + StringFour$ + StringFive$
  251.     i% = DoMsgBox( Message$, "MESSAGE", MB_TASKMODAL+MB_ICONQUESTION+MB_YESNO)
  252.     IF i%=6 THEN
  253.     ''** value of IDYES **
  254.         i%=SetupMicrotextHardware (hwndFrame)
  255.  
  256.         SourceDrive$ = "C:\~msstfqf.t\" + "TELETEXW.INF"
  257.         WinFile$ = MakePath ( DEST$, "TELETEXW.INF" )
  258.         CopyFile SourceDrive$, WinFile$, cmoNone, 0
  259.         RemoveFile SourceDrive$, cmoNone
  260.     ENDIF
  261.   
  262.     WinDrive$ = GetWindowsDir()
  263.     WinFile$ = WinDrive$ + "UPDATA.INI"
  264.     i%=DoesIniKeyExist( WinFile$, "CHARTS", "Window0" )
  265.     IF i% = 1 THEN
  266.     szEntry$= GetIniKeyString( WinFile$, "CHARTS", "Window0" )
  267.     i%=CheckIniEntry(hwndFrame,szEntry$,DEST$)
  268.     IF NOT i% = 1 THEN
  269.         RemoveIniSection WinFile$, "CHARTS", cmoNone
  270.     END IF
  271.     END IF
  272.  
  273. END SUB
  274.  
  275.  
  276.  
  277.  
  278.  
  279. '**
  280. '** Purpose:
  281. '**     Builds the copy list and performs all installation operations.
  282. '** Arguments:
  283. '**     none.
  284. '** Returns:
  285. '**     none.
  286. '*************************************************************************
  287. SUB Install STATIC
  288.  
  289.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  290.     CreateDir DEST$, cmoNone
  291.     CreateDir DEST$+"\temp", cmoNone
  292.     CreateDir DEST$+"\prices", cmoNone
  293.     CreateDir DEST$+"\export", cmoNone
  294.     CreateDir DEST$+"\download", cmoNone
  295.  
  296.     OpenLogFile MakePath(DEST$, "LOGFILE.OUT"), 0
  297.     WriteToLogFile ""
  298.     WriteToLogFile "  User chose as destination directory: '" + DEST$ + "'"
  299.     WriteToLogFile "  User chose option: '" + OPTCUR$ + "'"
  300.     WriteToLogFile ""
  301.     WriteToLogFile "May have had to create the directory: " + DEST$
  302.     WriteToLogFile ""
  303.  
  304.     AddSectionFilesToCopyList "Files", SrcDir$, DEST$
  305.     AddToBillboardList "mscuistf.dll", MODELESS_1,"Billboard_1DlgProc", 1
  306.     AddToBillboardList "mscuistf.dll", MODELESS_1,"Billboard_2DlgProc", 1
  307.     AddToBillboardList "mscuistf.dll", MODELESS_1,"Billboard_3DlgProc", 1
  308.     AddToBillboardList "mscuistf.dll", MODELESS_1,"Billboard_4DlgProc", 1
  309.     CopyFilesInCopyList
  310.  
  311.    
  312.  
  313.  
  314.     SetParameters
  315.  
  316.     CreateProgmanGroup "Updata Programs", "", cmoNone
  317.     ShowProgmanGroup  "Updata Programs", 1, cmoNone
  318.     CreateProgmanItem "Updata Programs", "Updata TeleShares v2.1 ", MakePath(DEST$,"telshare.exe"), "", cmoOverwrite
  319.     CreateProgmanItem "Updata Programs", "TeleShares Tutorial", MakePath(DEST$,"tel_tut.hlp"), "", cmoOverwrite
  320.     CreateProgmanItem "Updata Programs", "Teleshares Graphing", MakePath(DEST$,"tgraph.exe"), "", cmoOverwrite
  321.     szOther$ = DEST$ +  "\info.ico, 0, 0, 0, "
  322.    CreateProgmanItem "Updata Programs", "Updata Information", MakePath(DEST$,"udprods.wri"), szOther$, cmoOverwrite
  323.  
  324.     
  325.     
  326.   
  327.     CloseLogFile
  328.  
  329. END SUB
  330.  
  331.  
  332.  
  333. '**
  334. '** Purpose:
  335. '**     Appends a file name to the end of a directory path,
  336. '**     inserting a backslash character as needed.
  337. '** Arguments:
  338. '**     szDir$  - full directory path (with optional ending "\")
  339. '**     szFile$ - filename to append to directory
  340. '** Returns:
  341. '**     Resulting fully qualified path name.
  342. '*************************************************************************
  343. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  344.     IF szDir$ = "" THEN
  345.         MakePath = szFile$
  346.     ELSEIF szFile$ = "" THEN
  347.             MakePath = szDir$
  348.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  349.                 MakePath = szDir$ + szFile$
  350.         ELSE
  351.                 MakePath = szDir$ + "\" + szFile$
  352.     END IF
  353. END FUNCTION
  354.  
  355.  
  356. SUB CreateBackDrop STATIC
  357.  
  358.     SetWin%=SetWindowLong(HwndFrame,-16,449773568)
  359.     ShowWin%=ShowWindow(hwndFrame,3)
  360.  
  361. END SUB
  362.