I am shure I have seen this asked before so, I came up with a little function to do this. This is in two parts, the definitions used for the API calls and then the function its self.
VB Code:
' These are the definitions. Put these at the top of your form.
Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" ( _
ByVal hwndOwner As Long, _
ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" ( _
ByVal pidl As Long, _
ByVal pszPath As String) As Long
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Declare Function AddFontResource Lib "gdi32.dll" Alias "AddFontResourceA" ( _
ByVal lpFileName As String) As Long
Private Const CSIDL_FONTS = &H14
Private Const HWND_BROADCAST = &HFFFF&
Private Const WM_FONTCHANGE = &H1D
Private Type ITEMID
cb As Long
abID As Byte
End Type
Private Type ITEMIDLIST
mkid As ITEMID
End Type
Private Function GetSpecialFolder(lngCSIDL As Long) As String
Hi trying to register a font which is going to be used by my application and the user.
I have my script exactly doing the same as you have mentioned.
The problem I am facing is that when ever I register a font, though it can be seen along with list of other fonts, it can not be activated by choosing manually by the user. But my application can access the font and use it appropriately. The only way the user can use the registered font is by restarting the computer. This is not the case when manually place the font at windows/fonts folder.
Can some one help me understand what is going wrong and help me fix my problem. Your help is greatly appreciated. Thanks.