home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
On Hand
/
On_Hand_From_Softbank_1994_Release_2_Disc_2_1994.iso
/
00049
/
s
/
disk1
/
fonts001.ms_
/
fonts001.ms
Wrap
Text File
|
1992-03-11
|
15KB
|
477 lines
'**************************************************************************
'* MSSetup Script -- TrueType FontPack for Windows
'**************************************************************************
'''$DEFINE DEBUG ''Define for script development/debugging
'$INCLUDE 'setupapi.inc'
'$INCLUDE 'msdetect.inc'
'$INCLUDE 'mscpydis.inc' ''System
'$INCLUDE 'msttfont.inc'
''Boolean values
CONST FALSE = 0
CONST TRUE = 1
''Dialog ID's
CONST WELCOME = 100
CONST ASKQUIT = 200
CONST DESTPATH = 300
CONST EXITFAILURE = 400
CONST EXITQUIT = 600
CONST EXITSUCCESS = 700
CONST OPTIONS = 800
CONST APPHELP = 900
CONST BADPATH = 6400
CONST FNTSLIDER = 10000
''SendMessage() IDs
CONST WM_WININICHANGE = &H001A
CONST WM_FONTCHANGE = &H001D
''ExitWindows() parameter
CONST EW_RESTARTWINDOWS = &H42
''Bitmap ID
CONST LOGO = 1
''Miscellaneous constants
CONST REQUIREDFREESPACE = 3145728 '' 3 Mb required hard drive free space
CONST REQUIREDWINVERSION = &H030A '' Hex value for Windows Version 3.10
CONST MAXPATH = 256 '' Max characters in pathname
CONST REQUIREMENTSTITLE$ = "Setup Failed"
CONST WININI$ = "WIN.INI"
GLOBAL DEST$ ''Default destination directory.
GLOBAL CUIDLL$ ''Dialog box resources and code
GLOBAL TEMPDIR$ ''Restart directory
''External functions
DECLARE FUNCTION GetTempFileName LIB "kernel" (a%,b$,c%,d$) AS INTEGER
DECLARE FUNCTION GetProfileInt LIB "kernel" (a$,b$,c%) AS INTEGER
DECLARE FUNCTION SendMessage LIB "user" (a%,b%,c%,d$) AS INTEGER
DECLARE FUNCTION AddFontResource LIB "gdi" (a$) AS INTEGER
DECLARE FUNCTION ExitWindows LIB "user" (a&, b%) AS INTEGER
DECLARE SUB DoSortList LIB "mscuistf.dll" (a$)
''Internal functions and subroutines
DECLARE SUB CheckRequirements
DECLARE SUB Install
DECLARE SUB ConfirmQuit
DECLARE SUB RestartWindows
DECLARE FUNCTION InstallFontIsNew (ttfName$) AS INTEGER
DECLARE FUNCTION itoa (x&) AS STRING
DECLARE FUNCTION VersionString (v%) AS STRING
DECLARE FUNCTION GetTempDirName AS STRING
DECLARE FUNCTION InstallFontsNeedsReboot AS INTEGER
DECLARE FUNCTION EnableTTNeedsReboot AS INTEGER
'*************************************************************************
INIT:
''**OpenLogFile "C:\LogFile.out", 0
''**WriteToLogFile "C:\LogFile.out: Away we go......."
CUIDLL$ = "mscuistf.dll" ''Custom user interface dll
HELPPROC$ = "FHelpDlgProc" ''Help dialog procedure
DEST$ = GetWindowsSysDir() ''Windows system directory
SetBitmap CUIDLL$, LOGO
SetTitle "Microsoft TrueType Font Pack for Windows Setup"
szInf$ = GetSymbolValue("STF_SRCINFPATH")
IF szInf$ = "" THEN
szInf$ = GetSymbolValue("STF_CWDDIR") + "FONTS001.INF"
END IF
ReadInfFile szInf$
WELCOME:
sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$)
IF sz$ = "CONTINUE" THEN
UIPop 1
CheckRequirements
ELSE
ConfirmQuit
GOTO WELCOME
END IF
Install
QUIT:
ON ERROR GOTO ERRQUIT
IF ERR = 0 THEN
dlg% = EXITSUCCESS
ELSEIF ERR = STFQUIT THEN
dlg% = EXITQUIT
ELSE
dlg% = EXITFAILURE
END IF
QUITL1:
sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
IF sz$ = "REACTIVATE" THEN
GOTO QUITL1
END IF
UIPop 1
END
ERRQUIT:
msg$ = "Setup sources were corrupted. "
msg$ = msg + "For assistance, contact Microsoft product support."
i% = DoMsgBox(msg$, "Setup Failed", MB_OK+MB_TASKMODAL+MB_ICONHAND)
END
'*************************************************************************
'**
'** Purpose:
'** Builds the copy list and performs all installation operations.
'** Arguments:
'** none.
'** Returns:
'** none.
'*************************************************************************
SUB Install STATIC
IF EnableTTNeedsReboot() <> FALSE THEN
'' CreateScalableFontResource() fails work when TrueType is disabled.
'' We have changed TTEnabled in WIN.INI, but this will have no
'' effect until Windows is booted. There is no way for us
'' to automatically restart Windows and start SETUP.EXE again,
'' so we will have to ask the user to do it "by hand".
caption$ = "Setup"
body$ = "Your TrueType system was disabled. You will need to "
body$ = body$ + "quit and restart Windows to enable TrueType "
body$ = body$ + "and then run SETUP to install the TrueType "
body$ = body$ + "Font Pack."
mbFlags% = MB_OK + MB_TASKMODAL + MB_ICONHAND
ignore% = DoMsgBox (body$, caption$, mbFlags%)
STOP
END IF
WELCOMEL1:
WHILE InitSystem(1, "", 0) = 0
ConfirmQuit
WEND
SrcDir$ = GetSymbolValue("STF_SRCDIR")
'''' AddSectionFilesToCopyList "Files", SrcDir$, DEST$
AddSectionFilesToCopyList "Fonts", SrcDir$, DEST$
TEMPDIR$ = GetTempDirName()
SetRestartDir TEMPDIR$
CopyFilesInCopyList
ignore% = InstallFontsNeedsReboot()
'' We now ignore the return code from InstallFontsNeedsReboot()
'' because SETUP properly inserts .TTF files into the restart
'' list as of version 2.018.
IF RestartListEmpty() <> FALSE THEN
''**WriteToLogFile "Broadcasting msgs"
ignore% = SendMessage (-1, WM_WININICHANGED, 0, "fonts")
ignore% = SendMessage (-1, WM_FONTCHANGE, 0, "")
ELSE
RestartWindows
END IF
''**CloseLogFile
END SUB
'**
'** Purpose:
'** Checks system for minimum requirements.
'** Aborts if minimum system requirements are not met.
'*************************************************************************
SUB CheckRequirements STATIC
'' Check free space on destination (Windows) drive
freeSpace& = GetFreeSpaceForDrive (DEST$)
IF freeSpace& < REQUIREDFREESPACE THEN
msg$ = itoa(REQUIREDFREESPACE)
msg$ = msg$ + " bytes free space required on drive "
msg$ = msg$ + MID$(DEST$,1,1) + ":. "
msg$ = msg$ + itoa(freeSpace&) + " bytes free."
res% = DoMsgBox (msg$, REQUIREMENTSTITLE, MB_OK)
ERROR STFQUIT
END IF
'' Check windows Version
winVersion% = GetWindowsMajorVersion()*256 + GetWindowsMinorVersion()
IF winVersion% < REQUIREDWINVERSION THEN
msg$ = "Windows version "
msg$ = msg$ + VersionString(REQUIREDWINVERSION)
msg$ = msg$ + " or later required. "
msg$ = msg$ + "(v" + VersionString(winVersion%) + " detected.)"
res% = DoMsgBox (msg$, REQUIREMENTSTITLE, MB_OK)
ERROR STFQUIT
END IF
msg$ = ""
END SUB
'**
'** Purpose:
'** Creates a new ".FOT" TrueType font resource file,
'** and logs the file in the WIN.INI file.
'** If there is no existing font with the same name,
'** calls AddFontResource() to add it to GDI's font table.
'**
'** Argument:
'** Name of TTF file
'** (NOT a full pathname, but relative to Windows System directory).
'**
'** Returns:
'** TRUE to indicate that font was not already present in the system
'** FALSE otherwise.
'*************************************************************************
FUNCTION InstallFontIsNew (ttfNameArg$) STATIC AS INTEGER
newFont% = FALSE
ttfName$ = UCASE$(ttfNameArg$)
ttfPath$ = DEST$ + ttfName$
faceName$ = GetFaceName (ttfPath$)
''**WriteToLogFile "InstallFont: " + ttfPath$ + " is " + faceName$
IF faceName$ <> "" THEN
SetSymbolValue "CREATING_FONT", faceName$
sz$ = UIStartDlg(CUIDLL$,FNTSLIDER,"SliderDlgProc",APPHELP,HELPPROC$)
IF sz$ <> "CONTINUE" THEN
ConfirmQuit
END IF
section$ = "fonts"
key$ = faceName$ + " (TrueType)"
s$ = STRING$(32,64)
if GetProfileString (section$, key$, "", s$, 64) = 0 THEN
''**WriteToLogFile "In WIN.INI, " + key$ + "=" + s$
newFont% = TRUE
''**WriteToLogFile "newFont% = " + STR$(newFont%)
END IF
''**WriteToLogFile "CreateFOT ( " + ttfName$ + " ) = "
fotName$ = CreateFOT (ttfName$)
''**WriteToLogFile ttfName$ + " -> " + fotName
''**WriteToLogFile "newFont% = " + STR$(newFont%)
IF fotName$ <> "" THEN
CreateIniKeyValue WININI$,section$,key$,fotName$,cmoOverwrite
''**WriteToLogFile "Test newFont% <> FALSE ... " + STR$(newFont%)
IF newFont% <> FALSE THEN
fotName$ = DEST$ + fotName$
''**WriteToLogFile "AddFontResource ( " + fotName$ + " ) "
IF AddFontResource (fotName$) = 0 THEN
''**WriteToLogFile "AddFontResource () = 0."
newFont% = FALSE
END IF
END IF
END IF
END IF
''**WriteToLogFile ttfPath$+","+faceName$+"new="+STR$(newFont%)
ttfPath$ = ""
faceName$ = ""
key$ = ""
section$ = ""
s$ = ""
fotName$ = ""
ttfName$ = ""
InstallFontIsNew = newFont%
END FUNCTION
'**
'** Purpose:
'** Generates an ASCII representation of an integer,
'** WITHOUT leading space as prepended by STRING$().
'** Argument:
'** A signed integer.
'** Returns:
'** The string.
'*************************************************************************
FUNCTION itoa (x&) STATIC AS STRING
s$ = STR$(x&)
if x& >= 0 THEN
s$ = MID$(s$,2,LEN(s$)-1)
END IF
itoa = s$
END FUNCTION
'**
'** Purpose:
'** Generates an ASCII representation of a Windows version code.
'** Argument:
'** 2-byte Windows version code with major version in high order byte.
'** Returns:
'** Resulting human-readble ASCII version string.
'*************************************************************************
FUNCTION VersionString (v%) STATIC AS STRING
VersionString = itoa(v/256) + "." + itoa(v MOD 256)
END FUNCTION
'**
'** Purpose:
'** Locate the preferred temp directory (in case reboot is required.)
'** Arguments:
'** none
'** Returns:
'** Resulting fully qualified directory path name.
'*************************************************************************
FUNCTION GetTempDirName STATIC AS STRING
tmpPath$ = STRING$(32,MAXPATH)
tmpCode% = GetTempFileName (0, "zzz", 0, tmpPath$)
KILL tmpPath$
SPLITPATH tmpPath$,tmpDrv$,tmpDir$,tmpName$,tmpExt$
if LEN(tmpDir$) > 1 THEN
tmpDir$ = MID$(tmpDir$,1,LEN(tmpDir$)-1)
END IF
GetTempDirName = tmpDrv$ + tmpDir$
tmpPath$ = ""
tmpDrv$ = ""
tmpDir$ = ""
tmpName$ = ""
tmpExt$ = ""
END FUNCTION
'**
'** Purpose:
'** Asks the user if he is certain he wants to quit Setup.
'** Returns only if the user decides not to quit, otherwise esacpes
'** using ERROR handling.
'*************************************************************************
SUB ConfirmQuit STATIC
ASKQUIT_TOP:
sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
IF sz$ = "EXIT" THEN
UIPopAll
ERROR STFQUIT
ELSEIF sz$ = "REACTIVATE" THEN
GOTO ASKQUIT_TOP
ELSE
UIPop 1
END IF
sz$ = ""
END SUB
'**
'** Purpose:
'** Sets the "TrueType enabled" flag in WIN.INI
'** Arguments:
'** none
'** Returns:
'** TRUE if reboot is required for the change to take effect,
'** FALSE if no change was required.
'*************************************************************************
FUNCTION EnableTTNeedsReboot STATIC AS INTEGER
section$ = "TrueType"
key$ = "TTEnable"
profileValue% = GetProfileInt (section$, key$, 1)
''**WriteToLogFile "TTEnabled = " + STR$(profileValue%)
IF profileValue% = 1 THEN
EnableTTNeedsReboot = FALSE
ELSE
CreateIniKeyValue WININI$,section$,key$,"1",cmoOverwrite
EnableTTNeedsReboot = TRUE
END IF
key$ = ""
section$ = ""
END FUNCTION
'**
'** Purpose:
'** Installs all fonts listed in the "[Fonts]" section of the .INF file
'** Arguments:
'** none
'** Returns:
'** TRUE if reboot is required (some font replaces an existing font).
'** FALSE if no reboot is required.
'*************************************************************************
FUNCTION InstallFontsNeedsReboot STATIC AS INTEGER
needRestart% = FALSE
MakeListFromSectionFilename "FONTS_LIST", "Fonts"
DoSortList "FONTS_LIST"
listLength% = GetListLength ("FONTS_LIST")
if listLength% > 0 THEN
FOR item% = 1 TO listLength%
fontFile$ = GetListItem("FONTS_LIST", item%)
IF InstallFontIsNew (fontFile$) = FALSE THEN
needRestart% = TRUE
''**WriteToLogFile "InstallFontsNeedsReboot " + fontFile$
END IF
NEXT
SetSymbolValue "CREATING_FONT", ""
sz$ = UIStartDlg(CUIDLL$,FNTSLIDER,"SliderDlgProc",APPHELP,HELPPROC$)
UIPop 1
END IF
''**WriteToLogFile "InstallFontsNeedsReboot => " + STR$(needRestart%)
InstallFontsNeedsReboot = needRestart%
fontFile$ = ""
sz$ = ""
END FUNCTION
'**
'** Purpose:
'** Restarts Windows using ExitExecRestart() if there are files in
'** the GUI Setup Toolkit's Restart List, or using the ExitWindows()
'** kernel API call if the restart is necessary for other reasons.
'** Arguments:
'** none
'** Never returns, it either restarts windows or causes a
'** TRUE if reboot is required (some font replaces an existing font).
'** FALSE if no reboot is required.
'*************************************************************************
SUB RestartWindows STATIC
body$ = "Setup must restart Windows to complete this installation. "
caption$ = "Setup Complete"
complete$ = ""
FOR i% = 1 TO 1 '' No need for "TO 2"; ExitExecRestart() has a loop.
body$ = body$ + "Press OK to restart Windows and proceed."
ignore% = DoMsgBox (body$, caption$, MB_OK+MB_TASKMODAL+MB_ICONHAND)
ignore% = ExitExecRestart()
body$ = "Setup cannot restart Windows. "
body$ = body$ + "Please close all active applications. "
NEXT
caption$ = "Setup"
failmsg$ = "You must exit Windows and type the command _MSRSTRT"
failmsg$ = failmsg$ + " from " + TEMPDIR$
failmsg$ = failmsg$ + " to finish the installation."
ignore% = DoMsgBox (failmsg$, caption$, MB_OK+MB_TASKMODAL+MB_ICONHAND)
END ''Was ERROR STFQUIT, but that is too verbose.
END SUB