title: C# AddFontResource not working despite even after Windows restart
body: <p>I'm trying to install a font using C# code using the code below.</p>
  
  <p>Calling InstallFont doesn't throw any exceptions and returns 1. I thought this indicated it's installed the font. However the font does not appear in the list of installed fonts either in the Windows Fonts folder or when checking InstalledFontCollection, neither is it displayed in my software. I have tried restarting the computer after install but it is still not available.</p>
  
  <p>If I install the file manually by double clicking in Windows Explorer and clicking Install the font installs without issue.</p>
  
  <p>I am using C#, Visual Studio 2010, Microsoft .NET Framework 4.0 on a Windows 7 64bit operating system.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Many Thanks,
  Paul</p>
  
  <p>Manifest file includes:</p>
  
  <pre><code>requestedExecutionLevel level="requireAdministrator" uiAccess="false"
  </code></pre>
  
  <p>Application code:</p>
  
  <pre><code>[DllImport("user32.dll")]
  public static extern int SendMessage(int hWnd, uint Msg, int wParam, int lParam);
  [DllImport("gdi32.dll", EntryPoint = "AddFontResourceW", SetLastError = true)]
  public static extern int AddFontResource([In][MarshalAs(UnmanagedType.LPWStr)] string lpFileName);
  
  public static int InstallFont()        
  {
      InstalledFontCollection ifc = new InstalledFontCollection();
  
      if (ifc.Families.Any(item =&gt; item.Name == "Arial Narrow"))
          return 100; // Font already installed
  
      string filename = @"C:\Users\username\Downloads\ARIALN.TTF";
  
      const int WM_FONTCHANGE = 0x001D;
      const int HWND_BROADCAST = 0xffff;
  
      int added = AddFontResource(filename);
      SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
  
      return added;
  }
  </code></pre>