RemoveFontResourceExA function (wingdi.h)

The RemoveFontResourceEx function removes the fonts in the specified file from the system font table.

Syntax

BOOL RemoveFontResourceExA(
  [in] LPCSTR name,
  [in] DWORD  fl,
  [in] PVOID  pdv
);

Parameters

[in] name

A pointer to a null-terminated string that names a font resource file.

[in] fl

The characteristics of the font to be removed from the system. In order for the font to be removed, the flags used must be the same as when the font was added with the AddFontResourceEx function. See the AddFontResourceEx function for more information.

[in] pdv

Reserved. Must be zero.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. No extended error information is available.

Remarks

This function will only remove the font if the flags specified are the same as when then font was added with the AddFontResourceEx function.

When you try to replace an existing font file that contains a font with outstanding references to it, you might get an error that indicates that the original font can't be deleted because it’s in use even after you call RemoveFontResourceEx. If your app requires that the font file be replaced, to reduce the resource count of the original font to zero, call RemoveFontResourceEx in a loop as shown in this example code. If you continue to get errors, this is an indication that the font file remains loaded in other sessions. Make sure the font isn't listed in the font registry and restart the system to ensure the font is unloaded from all sessions.

Note  Apps where the original font file is in use will still be able to access the original file and won't use the new font until the font reloads. Call AddFontResourceEx to reload the font. We recommend that you call AddFontResourceEx the same number of times as the call to RemoveFontResourceEx succeeded as shown in this example code.
 

int i = 0;
while( RemoveFontResourceEx( FontFile, FR_PRIVATE, 0 ) )
{
    i++;
}

// TODO: Replace font file

while( i-- )
{
    AddFontResourceEx( FontFile, FR_PRIVATE, 0 );
}

Note

The wingdi.h header defines RemoveFontResourceEx as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header wingdi.h (include Windows.h)
Library Gdi32.lib
DLL Gdi32.dll

See also

AddFontResourceEx

Font and Text Functions

Fonts and Text Overview

SendMessage