int AddFontResource(lpszFilename) | |||||
LPCSTR lpszFilename; | /* address of filename | */ |
The AddFontResource function adds a font resource to the Windows font table. Any application can then use the font.
lpszFilename
Points to a character string that names the font resource file or that contains a handle of a loaded module. If this parameter points to a font resource filename, it must be a valid MS-DOS filename, including an extension, and the string must be null-terminated. The system passes this string to the LoadLibrary function if the font resource must be loaded.
The return value specifies the number of fonts added if the function is successful. Otherwise, it is zero.
Any application that adds or removes fonts from the Windows font table should send a WM_FONTCHANGE message to all top-level windows in the system by using the SendMessage function with the hwnd parameter set to 0xFFFF.
When font resources added by using AddFontResource are no longer needed, you should remove them by using the RemoveFontResource function.
The following example uses the AddFontResource function to add a font resource from a file, notifies other applications by using the SendMessage function, then removes the font resource by using the RemoveFontResource function:
AddFontResource("fontres.fon");
SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
.
. /* Work with the font. */
.
if (RemoveFontResource("fontres.fon")) {
SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
return TRUE;
}
else
return FALSE;