by Ben Pachol (1 Submission)
Category: Windows System Services
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 29th July 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Easy way to install fonts from vb application.
' uses file system object to copy fonts from a path provided
' by strPath parameter to the windows font directory.
' To use filesystemobject check microsoft scripting runtime
' in your project references.
Public Function InstallFonts(strPath As String) As Boolean
Dim strWinDirectory As String * 256
Dim strDirectory As String
Dim fs As FileSystemObject
On Error GoTo errhandler
' get windows directory
GetWindowsDirectory strWinDir, 256
strWinDirectory = Left(strWinDirectory, InStr(strWinDirectory, Chr(0)) - 1)
strWinDirectory = Left(strWinDirectory, InStr(strWinDirectory, " "))
strDirectory = Trim(strWinDirectory)
Set fs = New FileSystemObject
fs.CopyFile strPath & "\myFont1.TTF ", strDirectory & "\fonts\myFont1.TTF"
fs.CopyFile strPath & "\myFont2.TTF ", strDirectory & "\fonts\myFont2.TTF"
fs.CopyFile strPath & "\myFont3.TTF ", strDirectory & "\fonts\myFont3.TTF"
Set fs = Nothing
InstallFonts = True
Exit Function
errhandler:
InstallFonts = False
End Function