Question

This question already has an answer here:

I need to determine the highest .NET framework version installed on a desktop machine from C\C++ code. Looks like I can iterate the folders under %systemroot%\Microsoft.NET\Framework, but that seems kind of error prone. Is there a better way? Perhaps a registry key I can inspect? Thanks.

Was it helpful?

Solution

Use the Windows Registry location HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP.

OTHER TIPS

Registry keys for the .NET Framework start like this:

HKEY_LOCAL_MACHINE\Software\Microsoft\NET Framework Setup\NDP\

Depending on the version, the rest of the key will be different (check this page).

You can look up how to access the registry in MSDN article Using the registry in a C++ application.

If you're trying to do this from managed code, take a look at this article, which wraps all of the logic needed to determine if a specific Framework version is installed.

Otherwise, take a look at Aaron's blog post here, which gives a C/C++ method for doing the same thing.

The following is supposed to give you the answer, but it seems horribly broken :(

c:\Program Files>clrver
Versions installed on the machine:
v2.0.50727
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top