C# winform 检测当前电脑安装的.net framework版本

private static bool GetDotNetRelease(int release)

{
const string subkey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\";
using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(subkey))
{
if (ndpKey != null && ndpKey.GetValue("Release") != null)
{
return (int)ndpKey.GetValue("Release") >= release ? true : false;
}
return false;
}
}
 
//release是你需要检测的版本号,比如.NET4.0,输入4
posted @ 2019-05-30 11:39  CHPowerljp  阅读(1377)  评论(0编辑  收藏  举报