tags:

views:

73

answers:

5

I want to check if .Net 2.0 or greater is installed on the machine. I want to check in a way that when newer versions are released the old code works. Registry check is ideal as the code is in C++.

+3  A: 

This blog post should have all the information you need: http://blogs.msdn.com/b/astebner/archive/2007/11/29/6608419.aspx

Stephen Cleary
@stephen does not help as they check for entries per version 2, 3.5 or 4.
Rohit
@Rohit: What is the purpose of this check?
Stephen Cleary
To make sure 2.0 or above is installed as a prerequisite.
Rohit
@Rohit checking for 2.0 specifically (and possibly 4.0) then is appropriate. 3/3.5 can't be installed independently of 2.0 (in other words, if 3.5 is installed the 2.0 keys will also be present) and 4 is somewhat independent of the prior versions.
Logan Capaldo
A: 

I am assuming that you wanna check .net framework version while/before installing a software if thats the case why don't you consider NSIS installer. I can help you further if NSIS serves your purpose.

SunilK
thanks but NSIS will not do.
Rohit
A: 

Reading your question quite literally, I would suggest a bootstrapper which does the check, and then launches your .Net app.

Why? Because if your .Net app relies on a specific .Net version (example 3.0), and there is only v2.0 installed on the machine, then your app will crash. If you have a native bootstrapper .exe then you can check the registry using the WinAPI (thousands of examples already exist for this), then launch your .Net app.

An alternative is to check with a bootstrapper that relies only on .Net 2.0 - that version is fairly ubiquitous these days, the chances of a correctly patched and updated machine not having it are fairly small (the chances are greater if it is a pre-WinXP machine). Later versions of the .Net framework are backward compatable with v2.0 (although i am unsure if the reduced nature of the 4.0 CP framework still makes it fully compatable with v2.0).

slugster
+1  A: 

This detailed SO answer will tell you which registry keys you need to check.

Zach Johnson
A: 

There is no way to do it.

Rohit