如何使用c++查看系统中是否安装了.NET?
是否有任何API可用于查找系统中是否安装了.NET框架。 或者至少任何人都可以告诉我如何在 C++ 中自己完成此操作,以及如何找到 .NET 安装的路径(如果已安装)?
我该怎么做...
这方面的任何帮助将不胜感激......
Is there any API available to find the whether the .NET framework installed or not in the system. or atlest can any one give me idea how to do this our own in c++ and also how to find the path where .NET installed if it is installed??
How can i do this ...
Any Help in this regard will Be Appreciated Greately.....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
多年来,Aaron Stebner 发表了几篇关于如何做到这一点的文章。 .Net 3.5 发布后的最新更新可以在 此处找到,并包含进行检查的 C++ 代码。 检测主要基于注册表检查。
Aaron Stebner has posted several articles about how to do this over the years. His latest update following the release of .Net 3.5 can be found here, and includes C++ code to do the check. The detection is mainly based on registry checking.
方法如下:
LoadLibrary()
mscoree.dll,然后GetProcAddress()
并尝试检索的入口点>GetCORSystemDirectory()
,然后GetCORSystemDirectory()
。如果所有步骤均成功,则 .NET 已安装。 不要忘记错误处理 - 每个步骤都可能失败,您需要确保您的程序已为此做好准备。
Here's how:
LoadLibrary()
the mscoree.dll and thenGetProcAddress()
and try to retrieve the entry point forGetCORSystemDirectory()
and thenGetCORSystemDirectory()
via the retrieved pointer.If all steps succeed the .NET is installed. Don't forget error handling - each step can fail and you need to be sure your program is ready for that.