RemoveFontResource

2.x

  BOOL RemoveFontResource(lpszFile)    
  LPCSTR lpszFile; /* address of string for filename */

The RemoveFontResource function removes an added font resource from the specified file or from the Windows font table.

Parameters

lpszFile

Points to a string that names the font resource file or contains a handle of a loaded module. If this parameter points to the font resource file, the string must be null-terminated and have the MS-DOS filename format. If the parameter contains a handle, the handle must be in the low-order word and the high-order word must be zero.

Return Value

The return value is nonzero if the function is successful. Otherwise, it is zero.

Comments

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.

In some cases, the RemoveFontResource function may not remove the font resource immediately. If there are outstanding references to the resource, it remains loaded until the last logical font using it has been removed (deleted) by using the DeleteObject function.

Example

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 calling 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;

See Also

AddFontResource, DeleteObject, SendMessage