如何在 VB.NET 中的用户计算机上安装字体,以便 Word 等应用程序可以使用它? [英] How do I install a font on a user's machine in VB.NET so applications like Word can use it?

查看:27
本文介绍了如何在 VB.NET 中的用户计算机上安装字体,以便 Word 等应用程序可以使用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要在所有将使用我正在编写的应用程序的用户计算机上安装字体,该应用程序在 Word 中创建自定义文档.这是一种条形码字体.

Need to install a font on all user's machines that will use the application I am writing which creates custom documents in Word. It's a barcode font.

我已成功将字体添加到我的解决方案中,并将其构建操作设置为嵌入式资源,并且还成功编写了代码来检查该字体是否已安装在用户的系统上.

I've successfully added the font to my solution and set its build action to Embedded Resource and have also successfully written code to check if the font is already installed on the user's system.

现在我只需要弄清楚如何从我的解决方案中提取字体并将其安装到用户的机器上,就好像他们自己安装了字体以用于 Office 应用程序等.

Now I just need to figure out how to extract the font from my solution and install it onto the user's machine as if they installed the font themselves for use in Office applications, etc.

我发现的大多数示例都是在 VB.NET 应用程序内而不是在其外部使用字体,而我发现的那些似乎符合我的目的的示例并不适合我.

Most of the examples I've found out there are for using the font within the VB.NET application instead of outside it and the one's I have found which seem to fit my purpose aren't working for me.

推荐答案

将字体复制到 Windows 字体文件夹中,然后您需要将字体添加到注册表中.我自己没有尝试过这个,但我认为可以通过使用 ShellExecuteA api 以类似于 此处.

Copy the font into the Windows font folder and then you need to get the font added to the registry. I've not tried this myself, but I think it's possible to do this by opening the font using the ShellExecuteA api in a similar way to as seen here.

这里有一种 vbscript 方法,它可能作为起点有用,因为您可能能够在 VB.Net 中使用类似的语法和函数:嘿,脚本专家!如何使用脚本安装字体?

Here's a vbscript way of doing it that might be useful as a starting point since you might be able to use similar syntax and functions in VB.Net: Hey, Scripting Guy! How Can I Install Fonts Using a Script?

这篇关于如何在 VB.NET 中的用户计算机上安装字体,以便 Word 等应用程序可以使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆