C # code installs font files

Source: Internet
Author: User

Tag:ror   str   opera    need    string    sts   section   nts   sys   

 public class Fontoperate {[DllImport ("kernel32.dll", SetLastError = True)] static extern int Writeprofi        Lestring (String lpszsection, String lpszkeyname, string lpszstring);        [DllImport ("User32.dll")] public static extern int SendMessage (int hWnd, uint Msg, int wParam,        int lParam);        [DllImport ("GDI32")] public static extern int AddFontResource (string lpfilename); public static bool Installfont (string sfontfilename, String sfontname) {string _stargetfontpath = Strin G.format (@ "{0}\fonts\{1}", System.Environment.GetEnvironmentVariable ("windir"), sfontfilename);//System font Directory Strin G _sresourcefontpath = string.            Format (@ "{0}\font\{1}", System.Windows.Forms.Application.StartupPath, Sfontfilename);//Font directory try to install {if (!              File.exists (_stargetfontpath) && file.exists (_sresourcefontpath)) {int _nret;      File.Copy (_sresourcefontpath, _stargetfontpath);                    _nret = AddFontResource (_stargetfontpath);                _nret = writeprofilestring ("Fonts", Sfontname + "(TrueType)", sfontfilename);            }} catch {return false;        } return true; }} use using System;using system.collections.generic;using system.linq;using system.text;using UtilityHelper;namespace Lhcity_lms_client.test{class Program {static void Main (string[] args) {Fontoperate.insta            Llfont ("Simfang.ttf", "Simfang");        Console.ReadLine (); }    }}

  

C # code installs font files

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.