vb用代码安装字体
1个回答
展开全部
新建模块:
Declare Function AddFontResource Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFileName As String) As Long
窗体代码:
Private Sub Command1_Click()
Dim ziti As String
ziti = "c:\ziti.ttf" '需要安装的字体文件位置
tmp = Right(ziti, Len(ziti) - InStrRev(ziti, "\"))
FileCopy ziti, "c:\WINDOWS\Fonts\" & tmp
Dim lResult As Long
lResult = AddFontResource("c:\WINDOWS\Fonts\" & tmp)
If lResult = 2 Then
MsgBox "安装成功"
Else
MsgBox "安装失败"
End If
End Sub
Declare Function AddFontResource Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFileName As String) As Long
窗体代码:
Private Sub Command1_Click()
Dim ziti As String
ziti = "c:\ziti.ttf" '需要安装的字体文件位置
tmp = Right(ziti, Len(ziti) - InStrRev(ziti, "\"))
FileCopy ziti, "c:\WINDOWS\Fonts\" & tmp
Dim lResult As Long
lResult = AddFontResource("c:\WINDOWS\Fonts\" & tmp)
If lResult = 2 Then
MsgBox "安装成功"
Else
MsgBox "安装失败"
End If
End Sub
更多追问追答
追问
tmp变量未定义?
追答
'添加模块代码
Declare Function AddFontResource Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFileName As String) As Long
'添加窗体代码:
Private Sub Command1_Click()
Dim ziti As String
ziti = "d:\New (3).TTF" '需要安装的字体文件位置
tmp = Right(ziti, Len(ziti) - InStrRev(ziti, "\"))
Dim lResult As Long
lResult = AddFontResource("c:\WINDOWS\Fonts\" & tmp)
If lResult = 2 Then
MsgBox "安装成功"
Else
MsgBox "安装失败"
End If
End Sub
'已测试,运行正常,未发现tmp变量未定义提示,请采纳!
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
微测检测5.10
2023-05-10 广告
2023-05-10 广告
您好!建议咨 深圳市微测检测有限公司,已建立起十余个专业实验室,企业通过微测检测就可以获得一站式的测试与认 证解决方案;(EMC、RF、MFi、BQB、QI、USB、安全、锂电池、快充、汽车电子EMC、汽车手机互 联、语音通话质量),认证遇...
点击进入详情页
本回答由微测检测5.10提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询