'example submitted by Johnny J. Ortiz
Private Const HWND_BROADCAST = &HFFFF&
Private Const WM_FONTCHANGE = &H1D
Private Declare Function AddFontResource Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFileName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Sub Form_Load()
    Dim res As Long
    ' add the font
    res = AddFontResource("C:\Fonts\Nordic__.ttf")
    If res > 0 Then
        ' alert all windows that a font was added
        SendMessage HWND_BROADCAST, WM_FONTCHANGE, 0, 0
        MsgBox res & " fonts were added!"
    End If
End Sub

Close this window