如何以编程方式检查 Visio 是否已安装以及安装在何处?

发布于 2024-07-26 08:42:37 字数 493 浏览 3 评论 0原文

我正在构建一个 C# 应用程序,该应用程序导出要与 Visio 组织结构图向导一起使用的 CSV 文件。

如何检查 Visio 安装是否存在以及路径是什么?

最明显的方法是检查 C:\Program Files\Office12\ORGWIZ.EXE 是否存在,但这很大程度上取决于是否安装了 Visio 2007。

我的另一个想法是检查注册表,但是什么是最可靠的来源? 我查看了 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ 下的版本号,但在它们下面是一个 Visio\InstallRoot ,除了检查每个版本之外,它是完美的..

我在其他地方读到,我可以检查 Software\Microsoft\Windows\CurrentVersion\Uninstall\ 下的卸载信息,但这对于 Windows 组件来说看起来相当复杂......

I am building a C# application that exports a CSV file to be used with the Visio org chart wizard.

How can I check that an installation of Visio exists, and what path?

The most obvious method is checking if C:\Program Files\Office12\ORGWIZ.EXE exists, but that is fairly dependant on having Visio 2007 installed..

My other thought is checking the registry, but what is the most reliable source? I've looked under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ where there are version numbers, but underneath them is a Visio\InstallRoot which would be perfect except for checking each versions..

I read elsewhere that I could check Uninstall information under Software\Microsoft\Windows\CurrentVersion\Uninstall\, but that looks fairly complicated for Windows components...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不语却知心 2024-08-02 08:42:37

我会查找
注册表中的 HKEY_CLASSES_ROOT\Visio.Application。
如果不存在,则不安装。
如果确实存在,CurVer 子键将为您提供类似 Visio.Application.12 的内容
这告诉您安装的默认版本(可能是其他版本)

HKEY_CLASSES_ROOT\Visio.Application.12 子键 CLSID 将为您提供一个 guid:
{00021A20-0000-0000-C000-000000000046}

HKEY_CLASSES_ROOT\CLSID{00021A20-0000-0000-C000-000000000046} 依次会给你
子键“LocalServer32”
其中将包含 EXE 的路径。

C:\PROGRA~1\MICROS~4\Office12\VISIO.EXE /Automation

如您所见,在我的例子中它具有短路径形式。

I would do a lookup for
HKEY_CLASSES_ROOT\Visio.Application in the registry.
If it doesn't exist, no install.
If it does exist, the CurVer sub key will give you something like Visio.Application.12
That tells you the DEFAULT version that is installed (might be others)

HKEY_CLASSES_ROOT\Visio.Application.12 Sub Key CLSID will give you a guid:
{00021A20-0000-0000-C000-000000000046}

HKEY_CLASSES_ROOT\CLSID{00021A20-0000-0000-C000-000000000046} in turn will give you
Sub Key "LocalServer32"
Which will contain the path to the EXE.

C:\PROGRA~1\MICROS~4\Office12\VISIO.EXE /Automation

As you can see, in my case it has the short path form.

无力看清 2024-08-02 08:42:37

这是我的解决方案,基于 罗杰的回答:

    RegistryKey regVersionString = Registry.ClassesRoot.OpenSubKey("Visio.Drawing\\CurVer");
    Console.WriteLine("VERSION: " + regVersionString.GetValue(""));

    RegistryKey regClassId = Registry.ClassesRoot.OpenSubKey(regVersionString.GetValue("") + "\\CLSID");
    Console.WriteLine("CLSID: " + regClassId.GetValue(""));

    RegistryKey regInstallPath = Registry.ClassesRoot.OpenSubKey("CLSID\\" + regClassId.GetValue("") + "\\LocalServer32");
    Console.WriteLine("PATH: " + regInstallPath.GetValue(""));

Here is my solution, based on Roger's answer:

    RegistryKey regVersionString = Registry.ClassesRoot.OpenSubKey("Visio.Drawing\\CurVer");
    Console.WriteLine("VERSION: " + regVersionString.GetValue(""));

    RegistryKey regClassId = Registry.ClassesRoot.OpenSubKey(regVersionString.GetValue("") + "\\CLSID");
    Console.WriteLine("CLSID: " + regClassId.GetValue(""));

    RegistryKey regInstallPath = Registry.ClassesRoot.OpenSubKey("CLSID\\" + regClassId.GetValue("") + "\\LocalServer32");
    Console.WriteLine("PATH: " + regInstallPath.GetValue(""));
阿楠 2024-08-02 08:42:37

您能否检查 Visio 文件扩展名是否已注册以及注册到哪个应用程序?

http://www.dreamincode.net/code/snippet3159.htm

查看 < code>HKEY_CLASSES_ROOT\\.vsd,该键是否存在,值是什么? 将它们与一组指示应用程序已安装的值进行比较。

Could you just check if the Visio file extension is registered, and to what application?

http://www.dreamincode.net/code/snippet3159.htm

Look in HKEY_CLASSES_ROOT\\.vsd, does the key exist, what are the values? Compare them to a set of values which indicate the application is installed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文