Install Fonts Like Windows Explorer Right Click RRS feed

  • Question

  • I need to emulate what happens when you right click a font file in Windows Explorer and select "Install as shortcut." This is the same thing as viewing a font with the Windows Font Viewer, turning on the "Use shortcut" button and hitting the "Install" button.

    I've seen a bunch of code on this forum but I'm not sure what pieces I'd need. I saw this post that seems to indicate that I'll need to use the AddFontResource API and add an entry to registry (so the font's available next time they log on), which seems to make sense. BUT, they also appear to be copying the font to the fonts folder, which I don't want to do. I want to leave the font resource file where it is and have a shortcut that shows in the Windows\Fonts folder, which is the result of the install methods I describe above.

    Is there, perhaps, documentation somewhere that describes what APIs are being used with the above describe installation methods?

    Many thanks,

    Tuesday, November 13, 2018 3:48 AM

All replies

  • Hi,

    see the code:

     <DllImport("kernel32.dll", SetLastError:=True)>
        Private Shared Function WriteProfileString(ByVal lpszSection As String, ByVal lpszKeyName As String, ByVal lpszString As String) As Integer
        End Function
        Public Shared Function SendMessage(ByVal hWnd As Integer, ByVal Msg As UInteger, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
        End Function
        Public Shared Function AddFontResource(ByVal lpFileName As String) As Integer
        End Function
        Private Sub installFont()
            Dim WinFontDir As String = System.Environment.GetEnvironmentVariable("WINDIR") & "\fonts"
            Dim FontFileName As String = "DS-Digital Bold Italic.TTF"
            Dim FontName As String = "DS-Digital Bold Italic"
            Dim Ret As Integer
            Dim Res As Integer
            Dim FontPath As String
            FontPath = WinFontDir & "\" & FontFileName
            If Not File.Exists(FontPath) Then
                File.Copy(System.Windows.Forms.Application.StartupPath & "\DS-Digital Bold Italic.TTF", FontPath)
                Ret = AddFontResource(FontPath)
                Ret = WriteProfileString("fonts", FontName & "(TrueType)", FontFileName)
            End If
        End Sub

    Best Regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Wednesday, November 14, 2018 7:48 AM
  • Thanks for responding Alex, but this method copies the font files to the Windows\Fonts folder, I need to be able to load them as a shortcut leaving them on the network drive. This method also doesn't allow me to load older Type1 fonts, which can be loaded as described above, with a right click on the .PFM file.


    Thursday, November 15, 2018 3:14 AM
  • So Castorix31 had the brilliant idea of using FolderItemVerb.DoIt.

    I'd posted to another forum in error before I was pointed here. The whole sordid affair is here.

    Now that I have the install working, I'm on to the REMOVAL of those fonts. Any ideas would be greatly appreciated.


    Saturday, November 17, 2018 3:57 AM