Add a font with AddFontResource in VB2008

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Erik DHondt
    New Member
    • Feb 2014
    • 1

    Add a font with AddFontResource in VB2008

    this code won't work
    Code:
    Imports System.IO.File
    Imports System.Windows.Forms
    Public Class Declarations
        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, ByVal lParam As Long) As Long
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Const HWND_BROADCAST As Integer = &HFFFF&
            Const WM_FONTCHANGE As Integer = &H1D
            Dim fPath As String = Application.StartupPath()
    
            AddFontResource(fPath & "\UKVortaro.ttf")
            SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0)
    
            My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", "UKVortaro (TrueType)", "UKVortaro.ttf")
    
            Me.Close()
            End
        End Sub
    End Class
    Last edited by Rabbit; Feb 11 '14, 03:30 AM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
Working...