Determine highest .NET Framework version [duplicate]
Asked Answered
F

4

12

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.

Freudberg answered 8/10, 2008 at 13:58 Comment(0)
P
10

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

Propitious answered 8/10, 2008 at 14:2 Comment(1)
Yes, HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP should be a little easier. Looks like I'll have to iterate the subkeys and then query the Version value. Thanks.Freudberg
S
6

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.

Stimulate answered 8/10, 2008 at 14:9 Comment(0)
F
5

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.

Forestry answered 14/10, 2008 at 2:15 Comment(0)
A
0

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
Annabelleannabergite answered 8/10, 2008 at 13:59 Comment(1)
The CLR version is not necessarily the same as the .Net version. .Net v2.0 updated the CLR over v1.1, but .Net v3.0 & v3.5 did not change the CLR, so it remains "V2.0.50727"Kuehn

© 2022 - 2024 — McMap. All rights reserved.