如何使用c ++查找系统中是否安装了.NET?

时间:2022-08-27 06:58:55

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??

是否有任何API可用于查找系统中是否安装了.NET框架。或atlest可以任何人让我知道如何在c ++中做我们自己的这个,以及如何安装.NET安装的路径?

How can i do this ...

我怎样才能做到这一点 ...

Any Help in this regard will Be Appreciated Greately.....

这方面的任何帮助都会得到很好的赞赏......

2 个解决方案

#1


Here's how:

  • try to LoadLibrary() the mscoree.dll and then
  • 尝试LoadLibrary()mscoree.dll然后

  • pass the handle to the just loaded library to GetProcAddress() and try to retrieve the entry point for GetCORSystemDirectory() and then
  • 将句柄传递给刚加载的库到GetProcAddress()并尝试检索GetCORSystemDirectory()的入口点然后

  • try to call GetCORSystemDirectory() via the retrieved pointer.
  • 尝试通过检索到的指针调用GetCORSystemDirectory()。

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.

如果所有步骤都成功,则安装.NET。不要忘记错误处理 - 每个步骤都可能失败,您需要确保您的程序已做好准备。

#2


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.

多年来,Aaron Stebner发表了几篇关于如何做到这一点的文章。他可以在此处找到.Net 3.5发布后的最新更新,并包含用于检查的C ++代码。检测主要基于注册表检查。

#1


Here's how:

  • try to LoadLibrary() the mscoree.dll and then
  • 尝试LoadLibrary()mscoree.dll然后

  • pass the handle to the just loaded library to GetProcAddress() and try to retrieve the entry point for GetCORSystemDirectory() and then
  • 将句柄传递给刚加载的库到GetProcAddress()并尝试检索GetCORSystemDirectory()的入口点然后

  • try to call GetCORSystemDirectory() via the retrieved pointer.
  • 尝试通过检索到的指针调用GetCORSystemDirectory()。

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.

如果所有步骤都成功,则安装.NET。不要忘记错误处理 - 每个步骤都可能失败,您需要确保您的程序已做好准备。

#2


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.

多年来,Aaron Stebner发表了几篇关于如何做到这一点的文章。他可以在此处找到.Net 3.5发布后的最新更新,并包含用于检查的C ++代码。检测主要基于注册表检查。