什么是检测的最好的方式,如果安装了COM组件 [英] What is the best way to detect if a COM component is installed

查看:94
本文介绍了什么是检测的最好的方式,如果安装了COM组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个COM互操作程序集,我想检查从.NET应用程序是否我将要创建的组件安装在机器上。

I have a COM interop assembly, and I would like to check from a .NET application whether the component I'm about to create is installed on the machine.

我想提供一个不错的错误信息,如果没有安装。

I would like to provide a nice error message if it is not installed.

把实例成的try-catch是不是对我来说是很好的解决方案,因为我想缺少的安装和可能出现的其他错误之间distingwish。

Put the instantiation into try-catch is not a good solution for me, as I would like to distingwish between the missing installation and the other errors that may occur.

我的想法是检查与COM类ID的节点是否存在下的* HKEY_LOCAL_MACHINE \ SOFTWARE \ Classes下注册表\接口*路径。但有一个更好的办法?

My idea is to check whether the node with the COM class id exists in the registry under the *HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface* path. But is there a better approach?

推荐答案

我觉得最好的办法,遗憾的是,是尝试并创建实例。检查注册表不保证该组件实际上是存在于所有(如文件可能已被删除或移动后注册)。

I think the best way, unfortunately, is to try and instantiate it. Checking in the registry does not guarantee that the component is actually there at all (e.g. the file may have been deleted or moved post registration).

这篇关于什么是检测的最好的方式,如果安装了COM组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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