home *** CD-ROM | disk | FTP | other *** search
/ gdead.berkeley.edu / gdead.berkeley.edu.tar / gdead.berkeley.edu / pub / gdead / ibm / mmv2.exe / TITLE.MST < prev    next >
Text File  |  1994-12-18  |  16KB  |  491 lines

  1. '**************************************************************************
  2. '*
  3. '* TITLE.MST - Viewer Runtime Setup Script
  4. '*
  5. '* CUSTOMIZING TITLE.MST
  6. '*
  7. '* For a simple Setup routine, you just need to assign values to the 
  8. '* series of variables following the heading "Setup Variables". This
  9. '* script also provides for the following more-advanced options, which
  10. '* are supported by subroutines located later in this script:
  11. '*
  12. '* Option                                         See Subroutine
  13. '* ------------------------------------------     ---------------------
  14. '* Install more than one .MVB file                ModifyViewerIni
  15. '* Install Help title                             ModifyViewerIni
  16. '* Install custom DLLs                            ModifyViewerIni
  17. '* Install multiple Program Manager items         ModifyProgramManager
  18. '* Display a custom icon with the ProgMan item    ModifyProgramManager
  19. '* Install custom fonts                           RegisterCustomFonts
  20. '* Install Video for Windows runtime files        RegisterDrivers
  21. '*
  22. '* Each customization note starts with the heading CUSTOMIZATION.
  23. '*
  24. '**************************************************************************
  25.     
  26.     '' Global variables
  27.  
  28.     GLOBAL TitleShortName$
  29.     GLOBAL TitleLongName$
  30.     GLOBAL MVBFileName$
  31.     GLOBAL PromptForPath%
  32.     GLOBAL DefaultPath$
  33.     GLOBAL ProgManGroup$
  34.     GLOBAL ProgManItem$
  35.  
  36.     '' ****************************************************************
  37.     '' ** Setup Variables
  38.     '' ****************************************************************
  39.  
  40.     '' Set the following string to a short form of the title name
  41.     '' (for example, "Gallery")
  42.     '+
  43.     TitleShortName$ = "Viewer"
  44.  
  45.     '' Set the following string to a long form of the title name
  46.     '' (for example, "Viewer 2.0 Gallery")
  47.     '+
  48.     TitleLongName$ = "Microsoft Multimedia Viewer v2.0"
  49.  
  50.     '' Set the following variable to the name of the MVB file, without 
  51.     '' the filename extension (for example, "GALLERY")
  52.     '+
  53.         '' MVBFileName$ = "GALLERY"
  54.  
  55.     '' The following variable determines whether Setup prompts the user
  56.     '' to specify a directory in which to install title files. (Files
  57.     '' to be installed on the hard disk must be listed in the TITLE.INF 
  58.     '' file under the [Installed Title Files] section.) Specify one of
  59.     '' the following values:
  60.     ''
  61.     '' 0    Install title files in the Windows directory (default setting).
  62.     ''      This is an appropriate setting if you have a limited number
  63.     ''      of files to copy (for example, a single custom icon or DLL).
  64.     ''
  65.     '' 1    Display a dialog box to prompt the user for a directory in 
  66.     ''      which to install files
  67.     '+
  68.     PromptForPath% = 0
  69.  
  70.     '' If you have specified 1 in PromptForPath%, set the following 
  71.     '' variable to the default path that will be displayed in the dialog
  72.     '' box (for example, "C:\GALLERY").
  73.     '+
  74.     '' DefaultPath$ = ""
  75.  
  76.     '' Set the following variable to the name of the program manager 
  77.     '' group you would like to create (for example, "Viewer 2.0 Gallery")
  78.     '+
  79.     ProgManGroup$ = "Accessories"
  80.     
  81.     '' Set the following variable to the caption of the program manager 
  82.     '' item for your title (for example, "Gallery")
  83.     '+
  84.     ProgManItem$ = "Multimedia Viewer 2.0"
  85.     
  86.     '***********************************************************************
  87.     '** Mainline
  88.     '***********************************************************************
  89.  
  90.     GLOBAL CUIDLL$
  91.  
  92.     '' Include files
  93.     '$INCLUDE 'setupapi.inc'
  94.     
  95.     '' Custom UI dll
  96.     CUIDLL$ = "mscuistf.dll"
  97.     
  98.     '' Dialog ID's
  99.     CONST DESTPATH      = 1000
  100.     CONST APPHELP       = 2000
  101.     CONST TOOBIG        = 3000
  102.     CONST BADPATH       = 4000
  103.     CONST SUCCESS       = 5000
  104.     
  105.     '' Bitmap ID
  106.     CONST LOGO = 1
  107.     
  108.     '' Functions and subroutines
  109.     DECLARE FUNCTION AddFont LIB "mscuistf.dll" (szFont$, szName$) AS INTEGER
  110.     DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  111.     DECLARE FUNCTION GetTitleDir (szDefault$) AS STRING
  112.     DECLARE FUNCTION CopyFiles(szTitleDir$) AS INTEGER
  113.     DECLARE SUB RegisterFont(fontfile$, fontname$)
  114.     DECLARE SUB ModifyViewerIni
  115.     DECLARE SUB RegisterCustomFonts
  116.     '+ ModifyProgramManager now can be passed a directory as a parameter.
  117.     '+ The original version had no parameters.
  118.     DECLARE SUB ModifyProgramManager(szTitleDir$)
  119.  
  120.     DECLARE SUB ShowSuccess
  121.     DECLARE SUB RegisterDrivers
  122.     
  123.     '' The following statement turns size checking off. Set it to scmOnFatal 
  124.     '' to enable size checking, where Setup will compare the disk file size 
  125.     '' with the INF file size and report an error if they are not the same.
  126.     
  127.         '+ i% = SetSizeCheckMode(scmOnFatal)
  128.     i% = SetSizeCheckMode(scmOff)
  129.     
  130.     '' Set the title and banner bitmap. You must rebuild MSCUISTF.DLL to 
  131.     '' alter the banner bitmap.
  132.     '+
  133.     SetTitle "Microsoft Multimedia Viewer Setup"
  134.  
  135.     SetBitmap CUIDLL$, LOGO 
  136.     
  137.     '' Read in the INF file.
  138.     
  139.     ReadInfFile GetSymbolValue("STF_CWDDIR") + "TITLE.INF"
  140.     
  141.     '' Decide where to put title files
  142.     IF PromptForPath% = 1 THEN
  143.         szTitleDir$ = GetTitleDir(DefaultPath$)
  144.         IF szTitleDir$ = "" THEN
  145.             GOTO QUIT
  146.         ENDIF
  147.     ELSE
  148.         szTitleDir$ = GetWindowsDir()
  149.     ENDIF   
  150.  
  151.         '' Copy files
  152.     IF CopyFiles(szTitleDir$) = 0 THEN
  153.         GOTO QUIT
  154.     ENDIF
  155.  
  156.     '' Create the MVIEWER2.EXE MVB association 
  157.         '+
  158.     szWindowsDir$ = GetWindowsDir()
  159.     CreateIniKeyValue "WIN.INI", "Extensions", "MVB", szWindowsDir$ + "SYSTEM\MVIEWER2.EXE ^.MVB", cmoNone
  160.  
  161.     '' Register in VIEWER.INI
  162.     ModifyViewerIni
  163.  
  164.     '' Register custom fonts
  165.     RegisterCustomFonts
  166.  
  167.     '' Register drivers
  168.     RegisterDrivers
  169.  
  170.     '' Modify Program Manager        
  171.     '+ Here's where we pass the destination directory to the subroutine
  172.     ModifyProgramManager(szTitleDir$)    
  173.     
  174.     '' Success dialog
  175.     '+
  176.         '' ShowSuccess
  177.            PAUSE "Installation of"+CHR$(13)+"Microsoft Multimedia Viewer 2.0"+CHR$(13)+"is complete"
  178.  
  179.     '' Now start the title
  180.     '+
  181.     '' RUN "mviewer2.exe " + MVBFileName$ + ".MVB", NOWAIT
  182.  
  183. QUIT:
  184.     
  185.     END
  186.     
  187.  
  188. '*************************************************************************
  189. '** Purpose:
  190. '**     Prompts the user for a path for the title files
  191. '** Arguments:
  192. '**     szDefault$ - default path
  193. '** Returns:
  194. '**     New valid path name, or "" if the user quit.
  195. '*************************************************************************
  196.  
  197. FUNCTION GetTitleDir (szDefault$) STATIC AS STRING
  198.  
  199.     SetSymbolValue "String", TitleShortName$
  200.     SetSymbolValue "EditTextIn", szDefault$
  201.     SetSymbolValue "EditFocus", "ALL"
  202.  
  203.     GETPATH:
  204.  
  205.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, "FHelpDlgProc")
  206.  
  207.     IF sz$ = "CONTINUE" THEN
  208.         szTitleDir$ = GetSymbolValue("EditTextOut")
  209.         IF IsDirWritable(szTitleDir$) = 0 THEN
  210.  
  211.             BADPATH:
  212.  
  213.             sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfoDlgProc", 0, "")
  214.             IF sz$ = "REACTIVATE" THEN
  215.                 GOTO BADPATH
  216.             END IF
  217.             UIPop 1
  218.             GOTO GETPATH
  219.         END IF
  220.         UIPop 1
  221.         CreateDir szTitleDir$, cmoNone
  222.  
  223.     ELSEIF sz$ = "REACTIVATE" THEN
  224.         GOTO GETPATH
  225.  
  226.     ELSE
  227.         szTitleDir$ = ""
  228.  
  229.     END IF
  230.  
  231.     GetTitleDir = szTitleDir$
  232.  
  233. END FUNCTION
  234.  
  235.  
  236. '*************************************************************************
  237. '** Purpose:
  238. '**     Copies the files in the INF file
  239. '** Arguments:
  240. '**     szTitleDir$ - destination directory for the title files
  241. '** Returns
  242. '**     1 if files were copied, 0 otherwise
  243. '*************************************************************************
  244.  
  245. FUNCTION CopyFiles(szTitleDir$) STATIC AS INTEGER
  246.  
  247.     '' Add all system files to the copy list
  248.     AddSectionFilesToCopyList "System Files", GetSymbolValue("STF_SRCDIR"), GetWindowsSysDir()
  249.     
  250.     '' Add all of the title files to the copy list
  251.     '' AddSectionFilesToCopyList "Installed Title Files", GetSymbolValue("STF_SRCDIR"), szTitleDir$
  252.     
  253.     '' Check size
  254.     szExtras$ = "Extra"
  255.     szCosts$ = "Costs"
  256.     szNeededs$ = "Neededs"
  257.     FOR i% = 1 TO 26 STEP 1
  258.         AddListItem szExtras$, "0"
  259.     NEXT i%
  260.  
  261.     '' We assume that VIEWER.INI will take another 4K
  262.     ReplaceListItem szExtras$, ASC(MID$(GetWindowsDir(), 1, 1)) - ASC("A") + 1, STR$(4096)
  263.     
  264.     '' Get amount of space required
  265.     StillNeed& = GetCopyListCost(szExtras$, szCosts$, szNeededs$)
  266.     
  267.     '' Put up a message if there is not enough space
  268.     FOR i% = 1 TO 26 STEP 1
  269.         IF VAL(GetListItem(szNeededs$, i%)) > 0 THEN
  270.     
  271.             SetSymbolValue "String1", LTRIM$(STR$(VAL(GetListItem(szCosts$, i%)) / 1024))
  272.             SetSymbolValue "String2", CHR$(i% - 1 + ASC("A"))
  273.     
  274.             TOOBIG:
  275.     
  276.             sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfoDlgProc", 0, "")
  277.             IF sz$ = "REACTIVATE" THEN
  278.                 GOTO TOOBIG
  279.             END IF
  280.             UIPop 1
  281.             CopyFiles = 0
  282.             GOTO DONTCOPY
  283.         END IF
  284.     NEXT i%
  285.     
  286.     '' Copy the files
  287.     CopyFilesInCopyList
  288.     
  289.     CopyFiles = 1
  290.  
  291. DONTCOPY:
  292.  
  293. END FUNCTION
  294.  
  295.  
  296. '*************************************************************************
  297. '** Purpose:
  298. '**     Puts up a success dialog
  299. '*************************************************************************
  300.  
  301. SUB ShowSuccess STATIC
  302.  
  303.         SUCCESS:
  304.  
  305.         SetSymbolValue "String1", TitleShortName$
  306.         sz$ = UIStartDlg(CUIDLL$, SUCCESS, "FInfoDlgProc", 0, "")
  307.         IF sz$ = "REACTIVATE" THEN
  308.                 GOTO SUCCESS
  309.         END IF
  310.         UIPop 1
  311.  
  312. END SUB
  313.  
  314.  
  315. '*************************************************************************
  316. '** Purpose:
  317. '**     Appends a file name to the end of a directory path,
  318. '**     inserting a backslash character as needed.
  319. '** Arguments:
  320. '**     szDir$  - full directory path (with optional ending "\")
  321. '**     szFile$ - filename to append to directory
  322. '** Returns:
  323. '**     Resulting fully qualified path name.
  324. '*************************************************************************
  325.  
  326. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  327.     IF szDir$ = "" THEN
  328.         MakePath = szFile$
  329.     ELSEIF szFile$ = "" THEN
  330.         MakePath = szDir$
  331.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  332.         MakePath = szDir$ + szFile$
  333.     ELSE
  334.         MakePath = szDir$ + "\" + szFile$
  335.     END IF
  336. END FUNCTION
  337.  
  338.  
  339. '*************************************************************************
  340. '** Purpose:
  341. '**     Registers a font.
  342. '** Arguments:
  343. '**     fontfile$ - font filename
  344. '**     fontname$ - font name.
  345. '*************************************************************************
  346.  
  347. SUB RegisterFont(fontfile$, fontname$) STATIC
  348.  
  349.     '' A simple error catching wrapper around AddFont, which is a 'C' routine in MSCUISTF.DLL
  350.  
  351.     IF AddFont(fontfile$, fontname$) = -1 THEN
  352.         j% = DoMsgBox("Could not install " + fontfile$ + " font.", "Viewer Font Installation", 0)
  353.     ENDIF
  354.  
  355. END SUB
  356.  
  357.  
  358. '*************************************************************************
  359. '** Purpose:
  360. '**     Registers title in VIEWER.INI
  361. '*************************************************************************
  362.  
  363. SUB ModifyViewerIni STATIC
  364.  
  365.     '' Get the VIEWER.INI file
  366.     
  367.     szIni$ = MakePath(GetWindowsDir(), "VIEWER.INI")
  368.  
  369.     '' First register the title file, setting the Name and Path entries. 
  370.     '' We assume that the MVB file is the same directory as SETUP.EXE.
  371.     ''
  372.     '' CUSTOMIZATION: If you're installing multiple MVB files, copy the
  373.     '' following two statements for each additional file, substituting
  374.     '' the appropriate long name and MVB filename for the TitleLongName$
  375.     '' and MVBFileName$ variables.
  376.     '+
  377.         '' CreateIniKeyValue szIni$, MVBFileName$, "Name", TitleLongName$, cmoOverwrite
  378.         '' CreateIniKeyValue szIni$, MVBFileName$, "Path", GetSymbolValue("STF_SRCDIR"), cmoOverwrite
  379.  
  380.     '' Now we have to register the MVB file in the [FILES] section, so 
  381.     '' Viewer can find files that are not on the path and display a 
  382.     '' special message when a file is not found.
  383.     '+
  384.         '' CreateIniKeyValue szIni$, "FILES", MVBFileName$ + ".MVB", GetSymbolValue("STF_SRCDIR") + "," + "Please insert the " + TitleLongName$ + " disk.", cmoOverwrite
  385.  
  386.     '' CUSTOMIZATION: If you're installing a Help title or any custom DLLs,
  387.     '' you should copy the preceding statement for each extra title or DLL.
  388.     ''
  389.     '' Example for installing an extra title:
  390.     ''
  391.         '' CreateIniKeyValue szIni$, "FILES", "VWRHELP.MVB", GetSymbolValue("STF_SRCDIR") + "," + "Please insert the Illustrated Network Guide disk.", cmoOverwrite
  392.     ''
  393.     '' Example for installing a custom DLL:
  394.     ''
  395.     ''    CreateIniKeyValue szIni$, "FILES", "GALLERY.DLL", GetSymbolValue("STF_SRCDIR") + "," + "A required file is missing. Please reinstall the Viewer Gallery.", cmoOverwrite
  396.  
  397. END SUB
  398.  
  399.  
  400. '*************************************************************************
  401. '** Purpose:
  402. '**     Creates program manager entries for the title
  403. '*************************************************************************
  404.  
  405. SUB ModifyProgramManager(szDestDir$) STATIC
  406.  
  407.     '' Create the program manager group
  408.  
  409.     CreateProgmanGroup ProgmanGroup$, "", cmoNone
  410.     ShowProgmanGroup ProgmanGroup$, 1, cmoNone
  411.     
  412.     '' Create an entry for the title
  413.     '+
  414.     CreateProgmanItem ProgmanGroup$, ProgmanItem$, "mviewer2.exe " +  MakePath("", "" + ""), MakePath("", "" + "") + ",0,0,0," + szDestDir$, cmoOverwrite
  415.  
  416.     '' CUSTOMIZATION: 
  417.     ''
  418.     '' To create additional Program Manager items, copy the preceding 
  419.     '' statement for each additional item, substituting the appropriate
  420.     '' name for the MVBFileName$ variable.
  421.     ''
  422.     '' To display a custom icon with the Program Manager item, specify
  423.     '' the icon filename with the fourth parameter (this parameter is 
  424.     '' currently an empty string, ""). The following example specifies 
  425.     '' an icon with the same filename as the .MVB file:
  426.     ''
  427.     ''        CreateProgmanItem ProgmanGroup$, ProgmanItem$, "mviewer2.exe " + MakePath(GetSymbolValue("STF_SRCDIR"), MVBFileName$ + ".MVB"), MakePath(GetSymbolValue("STF_SRCDIR"), MVBFileName$ + ".ICO"), cmoOverwrite
  428.     
  429. END SUB
  430.  
  431.  
  432. '*************************************************************************
  433. '** Purpose:
  434. '**     Registers custom fonts with Windows.
  435. '*************************************************************************
  436.  
  437. SUB RegisterCustomFonts STATIC
  438.  
  439.     '' CUSTOMIZATION: If you install custom fonts, then add statements
  440.     '' in this routine to register the fonts with the current Windows 
  441.     '' session and to add them to the WIN.INI [Fonts] section. 
  442.     ''
  443.     '' Note that TrueType fonts can only be installed in Windows 3.1.
  444.     '' RegisterFont automatically creates the required .FOT file for 
  445.     '' TrueType fonts.
  446.     ''    
  447.     '' The following example registers a font residing in MISTRAL.TTF
  448.     '' and installs the font with the name Mistral (True Type):
  449.     '' 
  450.     ''     RegisterFont "mistral.ttf", "Mistral (TrueType)"
  451.     ''
  452.  
  453. END SUB
  454.  
  455.  
  456. '*************************************************************************
  457. '** Purpose:
  458. '**     Registers Windows drivers
  459. '*************************************************************************
  460.  
  461. SUB RegisterDrivers STATIC
  462.  
  463. '' CUSTOMIZATION: Video for Windows is not a standard component of
  464. '' Windows 3.1. If your title uses video, proceed as follows.
  465. ''
  466. '' 1) Add the following files to the [System Files] section of the INF file:
  467. ''
  468. ''    dispdib.dll
  469. ''    msvideo.dll
  470. ''    indeo.drv
  471. ''    mciavi.drv
  472. ''    msvidc.drv
  473. ''
  474. '' 2) Add the above files to your release directory. US versions can be 
  475. ''    found in the \SYSTEM subdirectory of your Viewer disc. French and
  476. ''    German versions were not available at ship time. Please contact 
  477. ''    Microsoft or check the Multimedia Viewer section on the Microsoft
  478. ''    Compuserve Forum for further details.
  479. ''
  480. '' 3) Uncomment the following lines:
  481. ''
  482. '' CreateIniKeyValue "WIN.INI", "mci extensions", "AVI", "AVIVIDEO", cmoNone
  483. '' CreateIniKeyValue MakePath(GetWindowsDir(), "SYSTEM.INI"), "mci", "AVIVIDEO", "MCIAVI.DRV", cmoNone
  484. '' CreateIniKeyValue MakePath(GetWindowsDir(), "SYSTEM.INI"), "drivers", "vidc.msvc", "msvidc.drv", cmoNone
  485. '' CreateIniKeyValue MakePath(GetWindowsDir(), "SYSTEM.INI"), "drivers", "vidc.rt21", "indeo.drv", cmoNone
  486.  
  487. END SUB
  488.  
  489.  
  490.  
  491.