Sie benötigen einen anderen Ansatz zur Installation von Schriftarten.
- einen Installer verwenden (erstellen ein Setup-Projekt) die Schriften
- Weitere (leichter) Ansatz zur Installation einer nativen Methode.
den Import DLL deklarieren:
[DllImport("gdi32.dll", EntryPoint="AddFontResourceW", SetLastError=true)]
public static extern int AddFontResource(
[In][MarshalAs(UnmanagedType.LPWStr)]
string lpFileName);
In Ihrem Code:
// Try install the font.
result = AddFontResource(@"C:\MY_FONT_LOCATION\MY_NEW_FONT.TTF");
error = Marshal.GetLastWin32Error();
Die Quelle:
http://www.brutaldev.com/post/2009/03/26/Installing-and-removing-fonts-using-C
ich es zusammen in einem Gerät zu testen, Ich hoffe, das hilft:
[TestFixture]
public class Tests
{
// Declaring a dll import is nothing more than copy/pasting the next method declaration in your code.
// You can call the method from your own code, that way you can call native
// methods, in this case, install a font into windows.
[DllImport("gdi32.dll", EntryPoint = "AddFontResourceW", SetLastError = true)]
public static extern int AddFontResource([In][MarshalAs(UnmanagedType.LPWStr)]
string lpFileName);
// This is a unit test sample, which just executes the native method and shows
// you how to handle the result and get a potential error.
[Test]
public void InstallFont()
{
// Try install the font.
var result = AddFontResource(@"C:\MY_FONT_LOCATION\MY_NEW_FONT.TTF");
var error = Marshal.GetLastWin32Error();
if (error != 0)
{
Console.WriteLine(new Win32Exception(error).Message);
}
}
}
, die Sie auf Ihrem Weg helfen sollten :)
Ich bin mir ziemlich sicher, dass neue Schriften mehr Installation beinhaltet als nur die Dateien in den Ordner Fonts fertig zu werden. – dtb
Hat das Erhöhen von Privilegien, unter denen die Anwendung läuft, das Problem gelöst? – abatishchev
Sie sollten eine andere Frage stellen: "Wie installiere ich eine Schriftart?". Ihre vorhandene Frage hat eine triviale Antwort: Ihr Benutzer hat keine Zugriffsrechte. Diese Antwort hilft dir nicht. – usr