Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Instalar fuente desde vb.net

334 views
Skip to first unread message

Daniel Martínez

unread,
Jan 5, 2004, 9:55:36 PM1/5/04
to
Alguien sabe como se instala una fuente (me refiero a un archivo .ttf que
tengo) en tiempo de ejecución en vb.net?

Muchas gracias.


christian strevel

unread,
Jan 6, 2004, 11:21:36 PM1/6/04
to
En teoria, podrías solamente copiar via programatica la fuente al directorio
windows/fonts y ya con eso, pero a lo mejor el sistema tendría que ser
rebooteado o bien, la fuente sea instalada correctamente (ej. windows no
reconozca el broadcast de install font que es parte del sistema op)

Tengo un codigo, que a lo mejor te puede servir como base para hacer esto...
pero esta en vb6:

Declare Function WriteProfileString Lib "Kernel" (ByVal _
lpApplicationName As String, ByVal lpKeyName As String, _
ByVal lpString As String) As Integer

Declare Function CreateScalableFontResource% Lib "GDI" _
(ByVal fHidden%, ByVal lpszResourceFile$, ByVal _
lpszFontFile$, ByVal lpszCurrentPath$) Declare Function _
AddFontResource Lib "GDI" (ByVal lpFilename As Any) As _
Integer

Declare Function SendMessage Lib "User" (ByVal hWnd As _
Integer, ByVal wMsg As Integer, ByVal wParam As _
Integer, lParam As Any) As Long
' This sub installs a TrueType font and makes it available
' to
' all Windows apps. It takes these arguments:
'
' FontName$ is the font's name (e.g. "Goudy Old Style")
'
' FontFileName$ is the font's filename (e.g. "GOUDOS.TTF")
'
' WinSysDir$ is the user's System folder (e.g.
' "C:\WINDOWS\SYSTEM"
' or "C:\WINDOWS\SYSTEM32")
'
' ** Before calling this sub, your code must copy the font
' file
' to the user's Fonts folder. **
'
Sub Install_TTF (FontName$, FontFileName$, WinSysDir$)
Dim Ret%, Res&, FontPath$, FontRes$
Const WM_FONTCHANGE = &H1D
Const HWND_BROADCAST = &HFFFF

FontPath$ = WinSysDir$ + "\" + FontFileName$
FontRes$ = Left$(FontPath$, Len(FontPath$) - 3) + "FOT"

Ret% = CreateScalableFontResource(0, FontRes$, _
FontFileName$, WinSysDir$)
Ret% = AddFontResource(FontRes$)
Res& = SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0)
Ret% = WriteProfileString("fonts", FontName + " " & _
"(TrueType)", FontRes$)
End SubSaludosChristian Strevelhttp://www.chris-strevel.com"Daniel Martínez"
<dan...@ya.com> wrote in message
news:eos7SCA1...@TK2MSFTNGP11.phx.gbl...

0 new messages