home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk1.iso / setup / faq.mst < prev    next >
Text File  |  1994-11-04  |  17KB  |  504 lines

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