473,395 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Add a font with AddFontResource in VB2008

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
0 1318

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

Similar topics

0
by: Helen W | last post by:
Hi In my vb.net Installer class, I check the InstalledFontCollection for myFont, if it isn't there I try to install it using the GDI function AddFontResource. I am getting the following error...
0
by: Rutger Hemrika | last post by:
Hello, I am developing a program which functions as a WYSIWYG for a special printer. This is an non-pcl printer which has it's own language. I already tapped into the winspool.drv to acces it...
3
by: 2G | last post by:
Hi How do you install a font using c# ? Copying it into the dir won't work. Grtz.
0
by: 2G | last post by:
Hi part 1 installing: I do the following to install a font File.Copy(f.Path, iPath + "\\" + n, true); AddFontResource(iPath + "\\" + n);
2
by: Johan Mårtensson | last post by:
Hi I was wondering if anyone knows how to install a system font using C#? I know it doesn´t do the trick to simply copy the font to the font directory, it just doesn´t become active. Any...
0
by: VMI | last post by:
How can I install a font through my program? I'm currently using AddFontResource(sPath) and it works as long as I open the Windows\Fonts folder after I execute AddFontResource. If I never open it,...
4
by: Johan | last post by:
Hi How would I go about installing a font file on WinXP? I have tried this and it won't get installed properly, private void installFont() { File.Copy(...
10
by: Sylvain Audet | last post by:
Hello! We have a Windows application that is using Crystal Reports reports containing Barcode fonts. Those reports are called through reflection into a Crystal Report Viewer and we need to have...
1
by: Willie jan | last post by:
Hi, i tried to install a font by using code like: res = CreateScalableFontResource(0, Fontlst.Item(i), Fontlst.Item(i), String.Empty) res = AddFontResource(Fontlst.Item(i)) That works fine...
1
by: Jim | last post by:
Hi, I'm a total C++ neophyte, and we've got a short deadline to turn around. Essentially, I need a utility that installs a series of fonts on a given system, and I don't know whether the .NET...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.