【问题标题】:install font ClickOnce but non RunAsAdmin安装字体 ClickOnce 但非 RunAsAdmin
【发布时间】:2013-11-21 06:57:28
【问题描述】:

在我的项目使用字体中, 用于在 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);

但错误:

对路径 '' 的访问被拒绝。

【问题讨论】:

    标签: c# fonts


    【解决方案1】:

    如果您的字体不需要在多个应用程序之间共享,您可以尝试私有字体部署,而不是在操作系统中安装它们。在这种情况下,您的应用不需要使用管理员帐户。

    私人部署有好的解决方案:Embedding/deploying custom font in .NET app

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多