Windows Dev Center

Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

RemoveFontResourceEx function

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

Syntax


BOOL RemoveFontResourceEx(
  _In_ LPCTSTR lpFileName,
  _In_ DWORD   fl,
  _In_ PVOID   pdv
);

Parameters

lpFileName [in]

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

fl [in]

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.

pdv [in]

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 );
}

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Wingdi.h (include Windows.h)

Library

Gdi32.lib

DLL

Gdi32.dll

Unicode and ANSI names

RemoveFontResourceExW (Unicode) and RemoveFontResourceExA (ANSI)

See also

Fonts and Text Overview
Font and Text Functions
AddFontResourceEx
SendMessage

 

 

Community Additions

Show:
© 2015 Microsoft