Determine highest .NET Framework version [duplicate]

拈花ヽ惹草 提交于 2019-11-27 17:56:34

问题


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.


回答1:


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




回答2:


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.




回答3:


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.




回答4:


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


来源:https://stackoverflow.com/questions/182910/determine-highest-net-framework-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!