예제 #1
0
        public bool Install()
        {
            if (Installed())
            {
                Console.WriteLine($"Failed to install font {Name}-{Family}: Can't install a font if the font is already installed");
                return(false);
            }

            try
            {
                FontInstaller.InstallFontFile(IntPtr.Zero, Path, FontInstallFlags.CopyAndInstall);

                // Alternative method
                //var shell = new Shell32.Shell();
                //var fontsDirectory = shell.NameSpace(0x14);
                //fontsDirectory.CopyHere(Path);

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Failed to install font {Name}-{Family}: {ex}");
                return(false);
            }
        }
예제 #2
0
파일: Form1.cs 프로젝트: harshana5/PowerUp
 public void InstallFont(string fontFilePath)
 {
     FontInstaller.CopyFontToWindowsFontFolder(fontFilePath);
 }