检测计算机已经安装的NetFramework版本(摘录)
Posted 小A
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了检测计算机已经安装的NetFramework版本(摘录)相关的知识,希望对你有一定的参考价值。
1 /// 2 /// 检测计算机已经安装的NetFramework版本 3 /// 4 internal void GetVersionFromRegistry() 5 { 6 using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, 7 RegistryView.Registry32).OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\")) 8 { 9 foreach (string versionKeyName in ndpKey.GetSubKeyNames()) 10 { 11 if (versionKeyName.StartsWith("v")) 12 { 13 RegistryKey versionKey = ndpKey.OpenSubKey(versionKeyName); 14 string name = (string)versionKey.GetValue("Version", ""); 15 string sp = versionKey.GetValue("SP", "").ToString(); 16 string install = versionKey.GetValue("Install", "").ToString(); 17 if (install == "") //no install info, ust be later 18 Console.WriteLine(versionKeyName + " " + name); 19 else 20 { 21 if (sp != "" && install == "1") 22 { 23 Console.WriteLine(versionKeyName + " " + name + " SP" + sp); 24 } 25 } 26 if (name != "") 27 { 28 continue; 29 } 30 foreach (string subKeyName in versionKey.GetSubKeyNames()) 31 { 32 RegistryKey subKey = versionKey.OpenSubKey(subKeyName); 33 name = (string)subKey.GetValue("Version", ""); 34 if (name != "") 35 sp = subKey.GetValue("SP", "").ToString(); 36 install = subKey.GetValue("Install", "").ToString(); 37 if (install == "") //no install info, ust be later 38 Console.WriteLine(versionKeyName + " " + name); 39 else 40 { 41 if (sp != "" && install == "1") 42 { 43 Console.WriteLine(" " + subKeyName + " " + name + " SP" + sp); 44 } 45 else if (install == "1") 46 { 47 Console.WriteLine(" " + subKeyName + " " + name); 48 } 49 } 50 } 51 } 52 } 53 } 54 }
以上是关于检测计算机已经安装的NetFramework版本(摘录)的主要内容,如果未能解决你的问题,请参考以下文章
iis安装.net后IIS不显示,安装.net提示已经安装了4.7或者更高的更新
Win10企业版安装NET Framework时出现"这台计算机中已经安装了.NET Framework 4.6.1或版本更高的更新"错误