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 AddFontResourceEx(string lpszFilename, uint fl, IntPtr pdv);
User-Defined Types:
None.
static extern int AddFontResource(string lpszFilename);
Notes:
Fonts added can be marked as private and not enumerable.
VB.NET Signature:
<DllImport("gdi32.dll")> _
Public Shared Function AddFontResource(string lpszFilename) As Integer
End Function
User-Defined Types:
None.
Tips & Tricks:
Please add some!
Notes:
To mark a font as private or non-enumerable, use the AddFontResourceEx function.
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);
//Alternatively PostMessage instead of SendMessage to prevent application hang
//bool posted = API.PostMessage(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!
The SendMessageTimeout API
5/24/2013 5:25:27 AM - -204.187.150.35
The PostMessage API
4/2/2016 12:09:27 PM - -78.110.196.168
The SendMessageTimeout API
5/24/2013 5:25:27 AM - -204.187.150.35
The PostMessage API
4/2/2016 12:09:27 PM - -78.110.196.168
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).