• 检测计算机已经安装的NetFramework版本(摘录)


       

     1         ///
     2         /// 检测计算机已经安装的NetFramework版本
     3       ///
     4         internal void GetVersionFromRegistry()
     5         {
     6             using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine,
     7                 RegistryView.Registry32).OpenSubKey(@"SOFTWAREMicrosoftNET Framework SetupNDP"))
     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         }
  • 相关阅读:
    【?】Hello。。。
    【Calc】对于‘精分’的研究
    [AFO]记五年oi生涯及CSP2019复赛游记
    CF#579div.3
    「BZOJ1827」奶牛大集会
    「BZOJ2821」作诗 && 「BZOJ2724」蒲公英
    「BZOJ4576」262144
    「Bzoj5055」膜法师
    「51nod1689」逛街
    「51nod1681」公共祖先 &&「51nod2553」双重祖先
  • 原文地址:https://www.cnblogs.com/xiaoa/p/5359065.html
Copyright © 2020-2023  润新知