BOOL RemoveFontResource(字体的安装路径);
因为是在CE里,所以是用Coredll PC机用的不是这个,可查MSDN
[DllImport("coredll", EntryPoint = "AddFontResource")]
private static extern int AddFontResource([In,MarshalAs( UnmanagedType.LPWStr)]string fontSource);
[DllImport("coredll", EntryPoint = "SendMessage")]
private static extern int SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
int installFont = AddFontResource(@"/SDMEM/MSYH.TTF"); //这是字体的安装 返回不为0即成功
SendMessage((IntPtr)0xffff, 0x001d, IntPtr.Zero, IntPtr.Zero); //通知其它正在运行的应用程序,有新字体注册了
//枚举字体
InstalledFontCollection enumFonts = new InstalledFontCollection();
FontFamily[] fonts = enumFonts.Families;
foreach (FontFamily font in fonts)
{
MessageBox.Show(font.Name);
}

本文介绍了如何在C#中使用`AddFontResource`和`RemoveFontResource`函数动态加载和卸载字体文件。通过指定字体文件路径,成功加载字体后,发送消息通知其他应用程序,并通过`InstalledFontCollection`枚举已安装的字体。
最低0.47元/天 解锁文章
249

被折叠的 条评论
为什么被折叠?



