0

in my Project Used Fonts, for install fonts when ClickOnce.

string strFontsPathFile = Environment.GetEnvironmentVariable("windir")
                + @"\Fonts\" + strFileName;
File.Copy(strFontFilePath, strFontsPathFile, true);

//2)Step 2 : Install font in resource of MS-Windows
if (AddFontResource(strFontsPathFile) == 0)
   return false;

//3)Step 3 : Set registry information of new installed font for use
RegistryKey reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", true);
reg.SetValue(strFileName.Split('.')[0] + " (TrueType)", strFileName);
reg.Close();
SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);

But Error:

Access to the path '' is denied.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364

1 Answers1

0

If your fonts don't need to be shared across multiple applications, you may try private font deployment instead of installing them in OS. In that case your app don't need to use administrator account.

There is the good solution for private deploment: Embedding/deploying custom font in .NET app

Community
  • 1
  • 1
Yan Sultanov
  • 146
  • 1
  • 3