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