Platform SDK: Installing Applications/Setup

Installing Fonts

By carrying out these steps, you can write a single font installation routine that works for both Windows NT/Windows 2000 and Windows 95/98:

If you use the installer, fonts are registered automatically.

  1. Determine whether the platform is Windows 95/98 or Windows NT/Windows 2000. This distinction is important because Windows 95/98 allows a shared network installation where most system files, including fonts, are stored on a centrally managed server. To determine the platform, look in the following registry location for a "SharedDir" value.
    HKeyLocalMachine\Software\Microsoft\Windows\CurrentVersion\Setup 
     

    The data value of "SharedDir" is the UNC name of the server and sharepoint of the shared directory. In most cases, a shared directory is marked as read-only by the system administrator, so your installation program should also check to see if it can write to this location. If it cannot, it should let the user install the fonts in a different location, or stop the setup process.

  2. Check whether the TrueTypeŽ font being installed is already present on the system by using the EnumFontFamilies function. If that font is present, the program should check to see if its version is newer by matching the installed font name with the filename on the disk. For Windows 95/98, the font name is stored in the following registry location.
    HKeyLocalMachine\Software\Microsoft\Windows\CurrentVersion\Fonts 
    

    For Windows NT/Windows 2000, the font name is stored in the following registry location.

    HKeyLocalMachine\Software\Microsoft\Windows NT\CurrentVersion\Fonts 
    

    The subkeys in this registry location contain the full name of the font file as the value key, followed by the filename of the .TTF file as the key data. If the filename in the registry is just a filename with no path information, the font is installed in the \WINDOWS\FONTS directory for Windows 95/98 or the \WINDOWS\SYSTEM directory for Windows NT/Windows 2000. Because TrueType font files do not carry a version resource, your program will need to retrieve the version string from the 'name' table in the .TTF file.