home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer 11 / 1995-10_Disc_11.iso / power / power.mst < prev    next >
Text File  |  1995-06-30  |  12KB  |  444 lines

  1. '* POWER.MST - PowerHouse Setup Script
  2. '**************************************************************************
  3.     
  4.     '' Global variables
  5.  
  6.     GLOBAL TitleShortName$
  7.     GLOBAL TitleLongName$
  8.     GLOBAL FileName$
  9.     GLOBAL PromptForPath%
  10.     GLOBAL DefaultPath$
  11.     GLOBAL ProgManGroup$
  12.     GLOBAL ProgManItem$
  13.     GLOBAL szTitleDir$
  14.  
  15.     '' WinG globals
  16.     
  17.     GLOBAL DEST$        ''Default destination directory.
  18.     GLOBAL bInstallDVA%
  19.  
  20.     '' ****************************************************************
  21.     '' ** Setup Variables
  22.     '' ****************************************************************
  23.  
  24.     '' Set the following string to a short form of the title name
  25.     
  26.         TitleShortName$ = "PowerHouse Demo"
  27.     
  28.     '' Set the following string to a long form of the title name
  29.     
  30.         TitleLongName$ = "PowerHouse Demo"
  31.         
  32.     '' Set the following variable to the name of the MVB file, without 
  33.         
  34.     FileName$ = "POWER"
  35.         
  36.     '' prompt for path BOOL
  37.     
  38.     PromptForPath% = 1
  39.         
  40.     '' install path when prompt is displayed                
  41.     
  42.         DefaultPath$ = "C:\POWDEM"
  43.     
  44.     '' program manager group 
  45.         
  46.         ProgManGroup$ = "PowerHouse Demo"
  47.     
  48.     '' program manager item title
  49.         
  50.         ProgManItem$ = "PowerHouse Demo"
  51.     
  52.     '***********************************************************************
  53.     '** Mainline
  54.     '***********************************************************************
  55.  
  56.     GLOBAL CUIDLL$
  57.  
  58.     '' Include files
  59.     '$INCLUDE 'setupapi.inc'
  60.     
  61.     '' Custom UI dll
  62.     CUIDLL$ = "mscuistf.dll"
  63.     
  64.     '' Dialog ID's
  65.     CONST DESTPATH      = 1000
  66.     CONST APPHELP       = 2000
  67.     CONST TOOBIG        = 3000
  68.     CONST BADPATH       = 4000
  69.     CONST SUCCESS       = 5000
  70.     CONST CONT_PH_SETUP = 101
  71.     CONST EXIT_PH_SETUP = 102
  72.  
  73.     '' WinG DLG ID's
  74.     CONST CHECK         = 2500
  75.     CONST EXITSUCCESS   = 700
  76.     CONST EXITFAILURE   = 400
  77.     CONST EXITQUIT      = 600
  78.     
  79.     '' Bitmap ID
  80.     CONST LOGO = 100
  81.     
  82.     '' Functions and subroutines
  83.     DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  84.     DECLARE FUNCTION GetTitleDir (szDefault$) AS STRING
  85.     DECLARE FUNCTION CopyFilesDisk1(szTitleDir$) AS INTEGER
  86.     DECLARE FUNCTION CopyFilesDisk2(szTitleDir$) AS INTEGER
  87.     DECLARE SUB ModifyProgramManager
  88.     DECLARE SUB ShowSuccess
  89.     
  90.     '' functions from WinG install
  91.     DECLARE FUNCTION GetRealWindowsSysDir AS STRING
  92.     DECLARE SUB UpdateWinG32 (szOrig$) 
  93.     DECLARE FUNCTION OnWin3x LIB "setuphlp.DLL" AS INTEGER
  94.     DECLARE FUNCTION VflatdPresent LIB "setuphlp.DLL" AS INTEGER
  95.     DECLARE FUNCTION GetRealSystemDir LIB "setuphlp.DLL" (szDir$,cbBuf%) AS INTEGER
  96.     DECLARE FUNCTION RestartWindows LIB "setuphlp.DLL" AS INTEGER
  97.     DECLARE FUNCTION IsWin32FileNewer LIB "setuphlp.DLL" (szOrig$,szNew$) AS INTEGER
  98.     DECLARE SUB RenameFilePlease LIB "setuphlp.DLL" (szOrig$,szNew$) 
  99.  
  100.     '' first we make a backup of the windows\system\dva.386 file
  101.     '' copy is called dva386.imp
  102.     '' problems occured with this file with certain versions of windows
  103.  
  104.     '' had problems running this .exe file
  105.     
  106.     szInf$ = GetSymbolValue("STF_SRCDIR")     
  107.     ''RUN szInf$+"saveme.exe "
  108.     
  109.     '' this section does exactly what the much larger preceding
  110.     '' program does but in only 2 lines
  111.     ''sz$ = GetWindowsSysDir
  112.     ''i% = FCopyOneFile (sz$+"dva.386",sz$+"dva386.imp",cmoCopy,0)
  113.  
  114.     '' return value displayer
  115.     ''i% = DoMsgBox(STR$(i%), "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  116.     
  117. INIT:
  118.     
  119.     bInstallDVA% = 0
  120.     
  121.     CUIDLL$ = "mscuistf.dll"            ''Custom user interface dll
  122.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  123.  
  124.     '' Set the title and banner bitmap. You must rebuild MSCUISTF.DLL to 
  125.     '' alter the banner bitmap.
  126.     
  127.     SetTitle "PowerHouse"
  128.     SetBitmap CUIDLL$, LOGO 
  129.         
  130. ''        sz$ = UIStartDlg(CUIDLL$, CONT_PH_SETUP, "FInfoDlgProc", APPHELP, HELPPROC$)      
  131. ''        IF sz$ <> "CONTINUE" THEN                
  132. ''                ERROR EXIT_PH_SETUP
  133. ''                GOTO QUIT
  134. ''        END IF    
  135. ''        UIPop 1
  136.  
  137.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  138.     IF szInf$ = "" THEN
  139.         szInf$ = GetSymbolValue("STF_CWDDIR") + "wing.inf"
  140.     END IF
  141.     ReadInfFile szInf$
  142.  
  143. CHECK:
  144.  
  145.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  146.     SrcDrive$ = MID$(SrcDir$,1,1)
  147.     SrcDir$ = SrcDrive$+":\SYSTEM\"
  148.     
  149.     ''i% = DoMsgBox(SrcDrive$, "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  150.     
  151.     DEST$ = GetWindowsSysDir
  152.     
  153.     AddSectionFilesToCopyList "runtime", SrcDir$, DEST$
  154.     
  155.     '
  156.     ' only use DVA on Windows 3.x
  157.     '
  158.     IF OnWin3x() = 1 THEN
  159.         AddSectionFilesToCopyList "dva", SrcDir$, DEST$
  160.         IF VflatdPresent() = 0 THEN
  161.         CreateSysIniKeyValue GetWindowsDir + "system.ini", "386Enh", "device", GetWindowsSysDir+"dva.386", cmoOverwrite
  162.         bInstallDVA% = 1
  163.         END IF
  164.     END IF
  165.     
  166.     DEST$ = GetRealWindowsSysDir
  167.     
  168.     AddSectionFilesToCopyList "wing32", SrcDir$, DEST$
  169.     Dest1$ = MakePath(DEST$,"wing32.dll")
  170.     Dest2$ = MakePath(DEST$,"wing32.xxx")
  171.     RenameFilePlease Dest1$,Dest2$
  172.     
  173.     CopyFilesInCopyList
  174.     
  175.     UpdateWinG32 GetRealWindowsSysDir()
  176.     
  177. POWER:        
  178.     '' now install powerhouse files
  179.     
  180.     '' The following statement turns size checking off. Set it to scmOnFatal 
  181.     '' to enable size checking, where Setup will compare the disk file size 
  182.     '' with the INF file size and report an error if they are not the same.
  183.     
  184.     i% = SetSizeCheckMode(scmOff)
  185.     
  186.     
  187.     '' Read in the INF file.
  188.     
  189.     ReadInfFile GetSymbolValue("STF_CWDDIR") + "POWER.INF"
  190.     
  191.     '' Decide where to put title files
  192.     IF PromptForPath% = 1 THEN
  193.         szTitleDir$ = GetTitleDir(DefaultPath$)
  194.         IF szTitleDir$ = "" THEN
  195.             ERROR STFQUIT
  196.             GOTO QUIT
  197.         ENDIF
  198.     ELSE
  199.         ''szTitleDir$ = GetWindowsDir()
  200.         szTitleDir$ = "C:\POWER"
  201.     ENDIF   
  202.     
  203.     '' Copy files
  204.     IF CopyFilesDisk1(szTitleDir$) = 0 THEN
  205.         GOTO QUIT
  206.     ENDIF
  207.     
  208.     ModifyProgramManager    
  209.     ShowSuccess
  210.     END
  211.  
  212. QUIT:
  213.     ON ERROR GOTO ERRQUIT
  214.  
  215.     IF ERR = 0 THEN
  216.     dlg% = EXITSUCCESS
  217.     ELSEIF ERR = STFQUIT THEN
  218.     dlg% = EXITQUIT
  219.     ELSEIF ERR = EXIT_PH_SETUP THEN
  220.     dlg% = EXIT_PH_SETUP
  221.     ELSE
  222.     dlg% = EXITFAILURE
  223.     END IF
  224.         
  225. ''    i% = DoMsgBox(STR$(ERR)+" "+STR$(dlg%), "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  226.     
  227.     
  228.     UIPop 1
  229.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfoDlgProc", 0, "")
  230.     END
  231.  
  232. ERRQUIT:
  233.     i% = DoMsgBox("Setup sources were corrupted, call 555-1212!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  234.     END
  235.     
  236.  
  237. '*************************************************************************
  238. '** Purpose:
  239. '**     Prompts the user for a path for the title files
  240. '** Arguments:
  241. '**     szDefault$ - default path
  242. '** Returns:
  243. '**     New valid path name, or "" if the user quit.
  244. '*************************************************************************
  245.  
  246. FUNCTION GetTitleDir (szDefault$) STATIC AS STRING
  247.  
  248.     SetSymbolValue "String", TitleShortName$
  249.     SetSymbolValue "EditTextIn", szDefault$
  250.     SetSymbolValue "EditFocus", "ALL"
  251.  
  252.     GETPATH:
  253.  
  254.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, "FHelpDlgProc")
  255.  
  256.     IF sz$ = "CONTINUE" THEN
  257.         szTitleDir$ = GetSymbolValue("EditTextOut")
  258.         IF IsDirWritable(szTitleDir$) = 0 THEN
  259.  
  260.             BADPATH:
  261.  
  262.             sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfoDlgProc", 0, "")
  263.             IF sz$ = "REACTIVATE" THEN
  264.                 GOTO BADPATH
  265.             END IF
  266.             UIPop 1
  267.             GOTO GETPATH
  268.         END IF
  269.         UIPop 1
  270.         CreateDir szTitleDir$, cmoNone
  271.  
  272.     ELSEIF sz$ = "REACTIVATE" THEN
  273.         GOTO GETPATH
  274.     ELSE
  275.         szTitleDir$ = ""
  276.  
  277.     END IF
  278.  
  279.     GetTitleDir = szTitleDir$
  280.  
  281. END FUNCTION
  282.  
  283.  
  284. '*************************************************************************
  285. '** Purpose:
  286. '**     Copies the files in the INF file
  287. '** Arguments:
  288. '**     szTitleDir$ - destination directory for the title files
  289. '** Returns
  290. '**     1 if files were copied, 0 otherwise
  291. '*************************************************************************
  292.  
  293. FUNCTION CopyFilesDisk1(szTitleDir$) STATIC AS INTEGER
  294.  
  295.     '' Add all system files to the copy list
  296.     AddSectionFilesToCopyList "System Files", GetSymbolValue("STF_SRCDIR"), GetWindowsSysDir()
  297.     
  298.     '' Add all of the title files to the copy list
  299.     AddSectionFilesToCopyList "Installed Title Files", GetSymbolValue("STF_SRCDIR"), szTitleDir$
  300.     
  301.     '' Check size
  302.     szExtras$ = "Extra"
  303.     szCosts$ = "Costs"
  304.     szNeededs$ = "Neededs"
  305.     FOR i% = 1 TO 26 STEP 1
  306.         AddListItem szExtras$, "0"
  307.     NEXT i%
  308.     
  309.     '' We assume that VIEWER.INI will take another 4K
  310.     ReplaceListItem szExtras$, ASC(MID$(UCASE$(GetWindowsDir()), 1, 1)) - ASC("A") + 1, STR$(4096)
  311.     
  312.     '' Get amount of space required
  313.     StillNeed& = GetCopyListCost(szExtras$, szCosts$, szNeededs$)
  314.     
  315.     '' Put up a message if there is not enough space
  316.     FOR i% = 1 TO 26 STEP 1
  317.         IF VAL(GetListItem(szNeededs$, i%)) > 0 THEN
  318.     
  319.             SetSymbolValue "String1", LTRIM$(STR$(VAL(GetListItem(szCosts$, i%)) / 1024))
  320.             SetSymbolValue "String2", CHR$(i% - 1 + ASC("A"))
  321.     
  322.             TOOBIG:
  323.     
  324.             sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfoDlgProc", 0, "")
  325.             IF sz$ = "REACTIVATE" THEN
  326.                 GOTO TOOBIG
  327.             END IF
  328.             UIPop 1
  329.             CopyFilesDisk1 = 0
  330.             GOTO DONTCOPY
  331.         END IF
  332.     NEXT i%
  333.     
  334.     '' Copy the files
  335.     CopyFilesInCopyList
  336.     
  337.     CopyFilesDisk1 = 1
  338.  
  339. DONTCOPY:
  340.  
  341. END FUNCTION
  342.  
  343. '*************************************************************************
  344. '** Purpose:
  345. '**     Puts up a success dialog
  346. '*************************************************************************
  347.  
  348. SUB ShowSuccess STATIC
  349.  
  350.     SUCCESS:
  351.     
  352.     SetSymbolValue "String1", TitleShortName$
  353.     sz$ = UIStartDlg(CUIDLL$, SUCCESS, "FInfoDlgProc", 0, "")
  354.     IF sz$ = "REACTIVATE" THEN
  355.         GOTO SUCCESS
  356.     END IF
  357.     UIPop 1
  358.     
  359. END SUB
  360.  
  361. '*************************************************************************
  362. '** Purpose:
  363. '**     Creates program manager entries for the title
  364. '*************************************************************************
  365.  
  366. SUB ModifyProgramManager STATIC
  367.  
  368.     '' Create the program manager group
  369.  
  370.     CreateProgmanGroup ProgmanGroup$, "", cmoNone
  371.     ShowProgmanGroup ProgmanGroup$, 1, cmoNone
  372.         CreateProgmanItem ProgmanGroup$, ProgmanItem$, szTitleDir$+"\POWHSDEM.EXE",szTitleDir$+"\POWERH.ICO",cmoOverwrite
  373.     
  374.         ''SrcDir$ = GetSymbolValue("STF_SRCDIR")
  375.         ''SrcDrive$ = MID$(SrcDir$,1,1)
  376.         ''CreateProgmanItem ProgmanGroup$, "The History of Energy", SrcDrive$+":\POWERON\POWERON.EXE",SrcDrive$+":\POWERON\POWERON.ICO",cmoOverwrite
  377.  
  378. END SUB
  379.  
  380. '**
  381. '** Purpose:
  382. '**     Appends a file name to the end of a directory path,
  383. '**     inserting a backslash character as needed.
  384. '** Arguments:
  385. '**     szDir$  - full directory path (with optional ending "\")
  386. '**     szFile$ - filename to append to directory
  387. '** Returns:
  388. '**     Resulting fully qualified path name.
  389. '*************************************************************************
  390. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  391.     IF szDir$ = "" THEN
  392.     MakePath = szFile$
  393.     ELSEIF szFile$ = "" THEN
  394.     MakePath = szDir$
  395.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  396.     MakePath = szDir$ + szFile$
  397.     ELSE
  398.     MakePath = szDir$ + "\" + szFile$
  399.     END IF
  400. END FUNCTION
  401.  
  402.  
  403. FUNCTION GetRealWindowsSysDir STATIC AS STRING
  404.     szBuf$ = string$(260, 32)
  405.     cbBuf% = GetRealSystemDir(szBuf$, 260)
  406.     IF cbBuf% = 0 THEN
  407.     ERROR STFERR
  408.     ELSE
  409.     IF cbBuf% > 259 THEN
  410.         res% = DoMsgBox("Buffer Overflow", "MS-Setup Error", MB_ICONHAND+MB_OK)
  411.         ERROR STFERR
  412.     END IF
  413.     szBuf$ = RTRIM$(szBuf$)
  414.     IF MID$(szBuf$, 1, 1) = "\" THEN
  415.         szBuf$ = MID$(CURDIR$, 1, 2) + szBuf$
  416.     ELSEIF MID$(szBuf$, 2, 1) <> ":" THEN
  417.         szBuf$ = MID$(CURDIR$, 1, 3) + szBuf$
  418.     END IF
  419.     IF MID$(szBuf$, LEN(szBuf$), 1) <> "\" THEN
  420.         szBuf$ = szBuf$ + "\"
  421.     END IF
  422.     GetRealWindowsSysDir = szBuf$
  423.     END IF
  424.  
  425.     szBuf$ = ""
  426. END FUNCTION
  427.  
  428. SUB UpdateWinG32 (szOrig$) STATIC 
  429.     '
  430.     ' Here we check the version ourselves of wing32.dll, since 
  431.     ' we can't get version checking for Win32 apps from Win16
  432.     '
  433.     FileNew$ = MakePath(szOrig$, "wing32.dll")
  434.     FileOrig$ = MakePath(szOrig$, "wing32.xxx")
  435.     IF IsWin32FileNewer( FileOrig$, FileNew$ ) THEN
  436.     RemoveFile FileOrig$, cmoForce
  437.     ELSE
  438.     RemoveFile FileNew$, cmoForce           ' get rid of new file
  439.     RenameFilePlease FileOrig$,FileNew$     ' put back old file
  440.     END IF
  441. END SUB
  442.  
  443.  
  444.