Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than gdi32, prefix the name with the module name and a period.
AddFontResource (gdi32)
.
C# Signature:
[DllImport("gdi32.dll")]
static extern int AddFontResource(string lpszFilename);
User-Defined Types:
None.
Notes:
To mark a font as private or non-enumerable, use the AddFontResourceEx function.
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);
[DllImport("gdi32.dll")]
static extern int AddFontResource(string lpFilename);
if (!fontFile.Exists)
{
Console.WriteLine("Font file not found.\n");
Usage();
return;
}
switch (args[0]) {
case "add" :
AddFontResource(args[1]);
break;
case "rem" :
RemoveFontResource(args[1]);
break;
default :
Usage();
return;
}
//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).