views:

118

answers:

2

Hi

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

+1  A: 

Here's how:

  • try to LoadLibrary() the mscoree.dll and then
  • pass the handle to the just loaded library to GetProcAddress() and try to retrieve the entry point for GetCORSystemDirectory() and then
  • try to call GetCORSystemDirectory() 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.

sharptooth
Hi sharptooth can u please look at the below link regarding yesterday discussion i have edited some more.http://stackoverflow.com/questions/1164069/whats-wrong-in-my-code-related-to-com
Cute
I've seen that, but how is that related to the problem of detecting .NET presense?
sharptooth
This is different one.I Have Manually given the normal installation path of.NET if it is not installed in that one suppose if .NET installed in D:\then it fails so i have to find the installtion path.
Cute
What's the problem again? You do all the steps in my answer and at the final step GetCORSystemDirectory() gives you the path to where .NET is installed.
sharptooth
+2  A: 

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.

adrianbanks