how do you make sure a font gets installed with your vb.net application

Posted on 2008-11-11
Medium Priority
Last Modified: 2012-05-05
I have a vb.net 2008 express application that needs a particular font installed on the users machine how do do that
Question by:Dov_B
  • 2
LVL 48

Assisted Solution

jpaulino earned 1400 total points
ID: 22934751
You can check in the windows\font\ if the font was already installed.
Something like:

        If IO.File.Exists("C:\WINDOWS\Fonts\FontName.ttf") Then
            ' font installed
        End If

Open in new window


Author Comment

ID: 22934839
I did not know that Thank you
but what I meant to ask is how do I tell vb.net to install the font
LVL 48

Accepted Solution

jpaulino earned 1400 total points
ID: 22934926
Check this example:
Public Class Form1
   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       IO.File.Copy("c:\Ayuma2yk.ttf", "c:\windows\fonts\Ayuma2yk.ttf", True)
   End Sub
End Class
Public Class FontUtil
   Private Declare Function AddFontResource Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFileName As String) As Long
   Private Declare Function RemoveFontResource Lib "gdi32" Alias "RemoveFontResourceA" (ByVal lpFileName As String) As Long
   ''' <summary>
   ''' Installs the font
   ''' </summary>
   ''' <param name="FileName">Name of the File </param>
   Public Shared Function InstallFont(ByVal FileName As String) As Boolean
       InstallFont = AddFontResource(FileName) <> 0
   End Function
   ''' <summary>
   ''' Uninstalls the font
   ''' </summary>
   ''' <param name="FileName"> Name of the File </param>
   Public Shared Function UninstallFont(ByVal FileName As String) As Boolean
       UninstallFont = RemoveFontResource(FileName) <> 0
   End Function
End Class

Open in new window

LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 600 total points
ID: 22935982

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question