zoukankan      html  css  js  c++  java
  • 【转】C#安装字体到系统

       [DllImport("kernel32.dll", SetLastError = true)]
            
    static extern int WriteProfileString(string lpszSection, string lpszKeyName, string lpszString);

            [DllImport("user32.dll")]
            
    public static extern int SendMessage(int hWnd, // handle to destination window 
            uint Msg, // message 
            int wParam, // first message parameter 
            int lParam // second message parameter 
            );

            [DllImport("gdi32")]
            
    public static extern int AddFontResource(string lpFileName);
              
            
    private void installFont()
            {

                string WinFontDir = "C:\\windows\\fonts";
                
    string FontFileName = "DS-Digital Bold Italic.TTF";
                
    string FontName = "DS-Digital Bold Italic";
                
    int Ret;
                
    int Res;
                
    string FontPath;
                
    const int WM_FONTCHANGE = 0x001D;
                
    const int HWND_BROADCAST = 0xffff;
                FontPath 
    = WinFontDir + "\\" + FontFileName;
                
    if (!File.Exists(FontPath))
                {
                    File.Copy(System.Windows.Forms.Application.StartupPath 
    + "\\DS-Digital Bold Italic.TTF", FontPath);
                    Ret 
    = AddFontResource(FontPath);

                    Res = SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 00);
                    Ret 
    = WriteProfileString("fonts", FontName + "(TrueType)", FontFileName);
                }
            }

  • 相关阅读:
    关于ceph的一些问题及解决
    Kubernetes 安装Rook ceph 1.5
    Flex布局语法教程
    MediaWiki安装随记
    Windows下的PHP开发环境搭建——PHP线程安全与非线程安全、Apache版本选择,及详解五种运行模式。
    windows的php7安装memcache扩展
    MediaWiki投放广告代码的几种办法
    mediawiki 常见配置功能
    mysql 添加用户 删除用户 赋权
    apache24配置php7
  • 原文地址:https://www.cnblogs.com/vic_lu/p/2827908.html
Copyright © 2011-2022 走看看