home *** CD-ROM | disk | FTP | other *** search
/ Internet Standards / CD1.mdf / ghost / ghost.mst < prev    next >
Text File  |  1994-11-10  |  15KB  |  462 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$ = "GhostScript"
  44.     
  45.     '' Set the following string to a long form of the title name
  46.     '' (for example, "Viewer 2.0 Gallery")
  47.     
  48.     TitleLongName$ = "GhostScript Postscript Viewer"
  49.         
  50.     '' Set the following variable to the name of the MVB file, without 
  51.     '' the filename extension (for example, "GALLERY")
  52.         
  53.     MVBFileName$ = ""
  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% = 1
  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$ = "C:\GS"
  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$ = "GhostScript"
  80.     
  81.     '' Set the following variable to the caption of the program manager 
  82.     '' item for your title (for example, "Gallery")
  83.         
  84.     ProgManItem$ = "GhostView"
  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.     DECLARE SUB ModifyProgramManager
  117.     DECLARE SUB ShowSuccess
  118.     DECLARE SUB RegisterDrivers
  119.     
  120.     '' The following statement turns size checking off. Set it to scmOnFatal 
  121.     '' to enable size checking, where Setup will compare the disk file size 
  122.     '' with the INF file size and report an error if they are not the same.
  123.     
  124.     i% = SetSizeCheckMode(scmOff)
  125.     
  126.     '' Set the title and banner bitmap. You must rebuild MSCUISTF.DLL to 
  127.     '' alter the banner bitmap.
  128.     
  129.     SetTitle "GhostScript/View Setup"
  130.     SetBitmap CUIDLL$, LOGO 
  131.     
  132.     '' Read in the INF file.
  133.     
  134.     ReadInfFile GetSymbolValue("STF_CWDDIR") + "GHOST.INF"
  135.     
  136.     szTitleDir$ = GetTitleDir(DefaultPath$)
  137.     IF szTitleDir$ = "" THEN
  138.         GOTO QUIT
  139.     ENDIF
  140.     szTitleDir$ = DefaultPath$
  141.     
  142.     '' Copy files
  143.     IF CopyFiles(szTitleDir$) = 0 THEN
  144.         GOTO QUIT
  145.     ENDIF
  146.  
  147.     '' Modify Program Manager
  148.     ModifyProgramManager    
  149.     
  150.     '' Success dialog
  151.     ShowSuccess
  152.     
  153.     '' Now start the title
  154. QUIT:
  155.     
  156.     END
  157.     
  158.  
  159. '*************************************************************************
  160. '** Purpose:
  161. '**     Prompts the user for a path for the title files
  162. '** Arguments:
  163. '**     szDefault$ - default path
  164. '** Returns:
  165. '**     New valid path name, or "" if the user quit.
  166. '*************************************************************************
  167.  
  168. FUNCTION GetTitleDir (szDefault$) STATIC AS STRING
  169.  
  170.     SetSymbolValue "String", TitleShortName$
  171.     SetSymbolValue "EditTextIn", szDefault$
  172.     SetSymbolValue "EditFocus", "ALL"
  173.  
  174.     GETPATH:
  175.  
  176.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, "FHelpDlgProc")
  177.  
  178.     IF sz$ = "CONTINUE" THEN
  179.         szTitleDir$ = GetSymbolValue("EditTextOut")
  180.         IF IsDirWritable(szTitleDir$) = 0 THEN
  181.  
  182.             BADPATH:
  183.  
  184.             sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfoDlgProc", 0, "")
  185.             IF sz$ = "REACTIVATE" THEN
  186.                 GOTO BADPATH
  187.             END IF
  188.             UIPop 1
  189.             GOTO GETPATH
  190.         END IF
  191.         UIPop 1
  192.         CreateDir szTitleDir$, cmoNone
  193.  
  194.     ELSEIF sz$ = "REACTIVATE" THEN
  195.         GOTO GETPATH
  196.  
  197.     ELSE
  198.         szTitleDir$ = ""
  199.  
  200.     END IF
  201.  
  202.     GetTitleDir = szTitleDir$
  203.  
  204. END FUNCTION
  205.  
  206.  
  207. '*************************************************************************
  208. '** Purpose:
  209. '**     Copies the files in the INF file
  210. '** Arguments:
  211. '**     szTitleDir$ - destination directory for the title files
  212. '** Returns
  213. '**     1 if files were copied, 0 otherwise
  214. '*************************************************************************
  215.  
  216. FUNCTION CopyFiles(szTitleDir$) STATIC AS INTEGER
  217.  
  218.     '' Add all system files to the copy list
  219.     AddSectionFilesToCopyList "Files", GetSymbolValue("STF_SRCDIR"), szTitleDir$
  220.     
  221.     '' Add all of the title files to the copy list
  222.     AddSectionFilesToCopyList "Fonts", GetSymbolValue("STF_SRCDIR"), "C:\GS\FONTS"
  223.     
  224.     '' Check size
  225.     szExtras$ = "Extra"
  226.     szCosts$ = "Costs"
  227.     szNeededs$ = "Neededs"
  228.     FOR i% = 1 TO 26 STEP 1
  229.         AddListItem szExtras$, "0"
  230.     NEXT i%
  231.     
  232.     '' We assume that VIEWER.INI will take another 4K
  233.     ReplaceListItem szExtras$, ASC(MID$(GetWindowsDir(), 1, 1)) - ASC("A") + 1, STR$(4096)
  234.     
  235.     '' Get amount of space required
  236.     StillNeed& = GetCopyListCost(szExtras$, szCosts$, szNeededs$)
  237.     
  238.     '' Put up a message if there is not enough space
  239.     FOR i% = 1 TO 26 STEP 1
  240.         IF VAL(GetListItem(szNeededs$, i%)) > 0 THEN
  241.     
  242.             SetSymbolValue "String1", LTRIM$(STR$(VAL(GetListItem(szCosts$, i%)) / 1024))
  243.             SetSymbolValue "String2", CHR$(i% - 1 + ASC("A"))
  244.     
  245.             TOOBIG:
  246.     
  247.             sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfoDlgProc", 0, "")
  248.             IF sz$ = "REACTIVATE" THEN
  249.                 GOTO TOOBIG
  250.             END IF
  251.             UIPop 1
  252.             CopyFiles = 0
  253.             GOTO DONTCOPY
  254.         END IF
  255.     NEXT i%
  256.     
  257.     '' Copy the files
  258.     CopyFilesInCopyList
  259.     
  260.     CopyFiles = 1
  261.  
  262. DONTCOPY:
  263.  
  264. END FUNCTION
  265.  
  266.  
  267. '*************************************************************************
  268. '** Purpose:
  269. '**     Puts up a success dialog
  270. '*************************************************************************
  271.  
  272. SUB ShowSuccess STATIC
  273.  
  274.     SUCCESS:
  275.     
  276.     SetSymbolValue "String1", TitleShortName$
  277.     sz$ = UIStartDlg(CUIDLL$, SUCCESS, "FInfoDlgProc", 0, "")
  278.     IF sz$ = "REACTIVATE" THEN
  279.         GOTO SUCCESS
  280.     END IF
  281.     UIPop 1
  282.     
  283. END SUB
  284.  
  285.  
  286. '*************************************************************************
  287. '** Purpose:
  288. '**     Appends a file name to the end of a directory path,
  289. '**     inserting a backslash character as needed.
  290. '** Arguments:
  291. '**     szDir$  - full directory path (with optional ending "\")
  292. '**     szFile$ - filename to append to directory
  293. '** Returns:
  294. '**     Resulting fully qualified path name.
  295. '*************************************************************************
  296.  
  297. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  298.     IF szDir$ = "" THEN
  299.         MakePath = szFile$
  300.     ELSEIF szFile$ = "" THEN
  301.         MakePath = szDir$
  302.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  303.         MakePath = szDir$ + szFile$
  304.     ELSE
  305.         MakePath = szDir$ + "\" + szFile$
  306.     END IF
  307. END FUNCTION
  308.  
  309.  
  310. '*************************************************************************
  311. '** Purpose:
  312. '**     Registers a font.
  313. '** Arguments:
  314. '**     fontfile$ - font filename
  315. '**     fontname$ - font name.
  316. '*************************************************************************
  317.  
  318. SUB RegisterFont(fontfile$, fontname$) STATIC
  319.  
  320.     '' A simple error catching wrapper around AddFont, which is a 'C' routine in MSCUISTF.DLL
  321.  
  322.     IF AddFont(fontfile$, fontname$) = -1 THEN
  323.         j% = DoMsgBox("Could not install " + fontfile$ + " font.", "Viewer Font Installation", 0)
  324.     ENDIF
  325.  
  326. END SUB
  327.  
  328.  
  329. '*************************************************************************
  330. '** Purpose:
  331. '**     Registers title in VIEWER.INI
  332. '*************************************************************************
  333.  
  334. SUB ModifyViewerIni STATIC
  335.  
  336.     '' Get the VIEWER.INI file
  337.     
  338.     szIni$ = MakePath(GetWindowsDir(), "VIEWER.INI")
  339.  
  340.     '' First register the title file, setting the Name and Path entries. 
  341.     '' We assume that the MVB file is the same directory as SETUP.EXE.
  342.     ''
  343.     '' CUSTOMIZATION: If you're installing multiple MVB files, copy the
  344.     '' following two statements for each additional file, substituting
  345.     '' the appropriate long name and MVB filename for the TitleLongName$
  346.     '' and MVBFileName$ variables.
  347.     
  348.     CreateIniKeyValue szIni$, MVBFileName$, "Name", TitleLongName$, cmoOverwrite
  349.     CreateIniKeyValue szIni$, MVBFileName$, "Path", GetSymbolValue("STF_SRCDIR"), cmoOverwrite
  350.     
  351.     '' Now we have to register the MVB file in the [FILES] section, so 
  352.     '' Viewer can find files that are not on the path and display a 
  353.     '' special message when a file is not found.
  354.  
  355.     CreateIniKeyValue szIni$, "FILES", MVBFileName$ + ".MVB", GetSymbolValue("STF_SRCDIR") + "," + "Please insert the " + TitleLongName$ + " disk.", cmoOverwrite
  356.  
  357.     '' CUSTOMIZATION: If you're installing a Help title or any custom DLLs,
  358.     '' you should copy the preceding statement for each extra title or DLL.
  359.     ''
  360.     '' Example for installing an extra title:
  361.     ''
  362.     ''    CreateIniKeyValue szIni$, "FILES", "GALHELP.MVB", GetSymbolValue("STF_SRCDIR") + "," + "Please insert the Viewer 2.0 Gallery disk.", cmoOverwrite
  363.     ''
  364.     '' Example for installing a custom DLL:
  365.     ''
  366.     ''    CreateIniKeyValue szIni$, "FILES", "GALLERY.DLL", GetSymbolValue("STF_SRCDIR") + "," + "A required file is missing. Please reinstall the Viewer Gallery.", cmoOverwrite
  367.  
  368. END SUB
  369.  
  370.  
  371. '*************************************************************************
  372. '** Purpose:
  373. '**     Creates program manager entries for the title
  374. '*************************************************************************
  375.  
  376. SUB ModifyProgramManager STATIC
  377.  
  378.     '' Create the program manager group
  379.  
  380.     CreateProgmanGroup ProgmanGroup$, "", cmoNone
  381.     ShowProgmanGroup ProgmanGroup$, 1, cmoNone
  382.     
  383.     '' Create an entry for the title
  384.      
  385.     CreateProgmanItem ProgmanGroup$, ProgmanItem$, "C:\GS\gsview.exe", "", cmoOverwrite
  386.     
  387.     '' CUSTOMIZATION: 
  388.     ''
  389.     '' To create additional Program Manager items, copy the preceding 
  390.     '' statement for each additional item, substituting the appropriate
  391.     '' name for the MVBFileName$ variable.
  392.     ''
  393.     '' To display a custom icon with the Program Manager item, specify
  394.     '' the icon filename with the fourth parameter (this parameter is 
  395.     '' currently an empty string, ""). The following example specifies 
  396.     '' an icon with the same filename as the .MVB file:
  397.     ''
  398.     ''       CreateProgmanItem ProgmanGroup$, ProgmanItem$, "mviewer2.exe " + MakePath(GetSymbolValue("STF_SRCDIR"), MVBFileName$ + ".MVB"), MakePath(GetSymbolValue("STF_SRCDIR"), MVBFileName$ + ".ICO"), cmoOverwrite
  399.  
  400. END SUB
  401.  
  402.  
  403. '*************************************************************************
  404. '** Purpose:
  405. '**     Registers custom fonts with Windows.
  406. '*************************************************************************
  407.  
  408. SUB RegisterCustomFonts STATIC
  409.  
  410.     '' CUSTOMIZATION: If you install custom fonts, then add statements
  411.     '' in this routine to register the fonts with the current Windows 
  412.     '' session and to add them to the WIN.INI [Fonts] section. 
  413.     ''
  414.     '' Note that TrueType fonts can only be installed in Windows 3.1.
  415.     '' RegisterFont automatically creates the required .FOT file for 
  416.     '' TrueType fonts.
  417.     ''    
  418.     '' The following example registers a font residing in MISTRAL.TTF
  419.     '' and installs the font with the name Mistral (True Type):
  420.     '' 
  421.     ''     RegisterFont "mistral.ttf", "Mistral (TrueType)"
  422.     ''
  423.  
  424. END SUB
  425.  
  426.  
  427. '*************************************************************************
  428. '** Purpose:
  429. '**     Registers Windows drivers
  430. '*************************************************************************
  431.  
  432. SUB RegisterDrivers STATIC
  433.  
  434. '' CUSTOMIZATION: Video for Windows is not a standard component of
  435. '' Windows 3.1. If your title uses video, proceed as follows.
  436. ''
  437. '' 1) Add the following files to the [System Files] section of the INF file:
  438. ''
  439. ''    dispdib.dll
  440. ''    msvideo.dll
  441. ''    indeo.drv
  442. ''    mciavi.drv
  443. ''    msvidc.drv
  444. ''
  445. '' 2) Add the above files to your release directory. US versions can be 
  446. ''    found in the \SYSTEM subdirectory of your Viewer disc. French and
  447. ''    German versions were not available at ship time. Please contact 
  448. ''    Microsoft or check the Multimedia Viewer section on the Microsoft
  449. ''    Compuserve Forum for further details.
  450. ''
  451. '' 3) Uncomment the following lines:
  452. ''
  453. '' CreateIniKeyValue "WIN.INI", "mci extensions", "AVI", "AVIVIDEO", cmoNone
  454. '' CreateIniKeyValue MakePath(GetWindowsDir(), "SYSTEM.INI"), "mci", "AVIVIDEO", "MCIAVI.DRV", cmoNone
  455. '' CreateIniKeyValue MakePath(GetWindowsDir(), "SYSTEM.INI"), "drivers", "vidc.msvc", "msvidc.drv", cmoNone
  456. '' CreateIniKeyValue MakePath(GetWindowsDir(), "SYSTEM.INI"), "drivers", "vidc.rt21", "indeo.drv", cmoNone
  457.  
  458. END SUB
  459.  
  460.  
  461.  
  462.