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.
views:
1522answers:
4
                +6 
                A: 
                
                
              HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP
Is that what you're looking for?
                  chills42
                   2008-10-08 14:02:46
                
              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.
                  Charles
                   2009-02-02 21:35:37
                
                +4 
                A: 
                
                
              
            Registry keys for the .Net Framework start like that:
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 how to access the registry in this msdn article: Using the registry in a C++ application.
                  Luc Touraille
                   2008-10-08 14:09:56
                
              
                
                A: 
                
                
              The following is suppose to give you the answer, but it seems horribly broken :(
c:\Program Files>clrver
Versions installed on the machine:
v2.0.50727
                  leppie
                   2008-10-08 14:10:43
                
              
                  
                  James Curran
                   2008-10-08 14:51:17
                
              
                +4 
                A: 
                
                
              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.
                  Scott Dorman
                   2008-10-14 02:15:32
                
              @Daniel Daranas: Thanks for letting me know. Code Project moved the article since this was originally answered. I've updated the answer to the correct link.
                  Scott Dorman
                   2010-04-29 17:26:26