By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,616 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Add a font with AddFontResource in VB2008

P: 1
this code won't work
Expand|Select|Wrap|Line Numbers
  1. Imports System.IO.File
  2. Imports System.Windows.Forms
  3. Public Class Declarations
  4.     Private Declare Function AddFontResource Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFileName As String) As Long
  5.     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
  6.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  7.         Const HWND_BROADCAST As Integer = &HFFFF&
  8.         Const WM_FONTCHANGE As Integer = &H1D
  9.         Dim fPath As String = Application.StartupPath()
  10.  
  11.         AddFontResource(fPath & "\UKVortaro.ttf")
  12.         SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0)
  13.  
  14.         My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", "UKVortaro (TrueType)", "UKVortaro.ttf")
  15.  
  16.         Me.Close()
  17.         End
  18.     End Sub
  19. End Class
Feb 10 '14 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.