Desktop Functions:

   Smart Device Functions:

Show Recent Changes
Subscribe (RSS)
Misc. Pages
Helpful Tools
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
RemoveFontResource (gdi32)

C# Signature:

static extern bool RemoveFontResource(string lpFileName);

User-Defined Types:




Tips & Tricks:

Please add some!

Sample Code:

  using System;
  using System.Collections.Generic;
  using System.Text;
  using System.IO;
  using System.Runtime.InteropServices;

  namespace FontResource
    class Program
    private static IntPtr HWND_BROADCAST = new IntPtr(0xffff);
    private static IntPtr HWND_TOP = new IntPtr(0);
    private static IntPtr HWND_BOTTOM = new IntPtr(1);
    private static IntPtr HWND_TOPMOST = new IntPtr(-1);
    private static IntPtr HWND_NOTOPMOST = new IntPtr(-2);
    private static IntPtr HWND_MESSAGE = new IntPtr(-3);

    static extern int AddFontResource(string lpFilename);

    static extern bool RemoveFontResource(string lpFileName);

    private static extern int SendMessage(IntPtr hWnd, WindowsMessages wMsg, IntPtr wParam, IntPtr lParam);

    static void Main(string[] args)
        if (args.Length < 2) { Usage(); return; }

        FileInfo fontFile = new FileInfo(args[1]);

        if (!fontFile.Exists)
        Console.WriteLine("Font file not found.\n");

        switch (args[0]) {
        case "add" :
        case "rem" :
        default :

        //This version of SendMessage is a blocking call until all windows respond.
        long result = SendMessage(HWND_BROADCAST, WindowsMessages.WM_FONTCHANGE, IntPtr.Zero, IntPtr.Zero);

        Console.WriteLine(String.Format("WM_FONTCHANGE broadcast returned {0}", result));

    public static void Usage()
        Console.WriteLine("FontResource [add|rem] <font>");
        Console.WriteLine("\nAny changes will not persist a reboot - to do so, remove the font entry from the registry.");

    public enum WindowsMessages
        //Snipped for length - see the list of WM_ calls on this site.

Alternative Managed API:

Do you know one? Please contribute it!


Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

Access directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version