Detecting the NETFramework version (excerpt) that the computer has installed

Source: Internet
Author: User

   

1         ///2         ///detecting netframework versions of computers that have been installed3       ///4         Internal voidgetversionfromregistry ()5         {6             using(RegistryKey Ndpkey =Registrykey.openbasekey (Registryhive.localmachine,7REGISTRYVIEW.REGISTRY32). OpenSubKey (@"software\microsoft\net Framework setup\ndp\"))8             {9                 foreach(stringVersionkeynameinchndpkey.getsubkeynames ())Ten                 { One                     if(Versionkeyname.startswith ("v")) A                     { -RegistryKey Versionkey =Ndpkey.opensubkey (versionkeyname); -                         stringName = (string) Versionkey.getvalue ("Version",""); the                         stringSP = Versionkey.getvalue ("SP",""). ToString (); -                         stringInstall = Versionkey.getvalue ("Install",""). ToString (); -                         if(Install = ="")//no install info, ust be later -Console.WriteLine (Versionkeyname +"  "+name); +                         Else -                         { +                             if(sp! =""&& Install = ="1") A                             { atConsole.WriteLine (Versionkeyname +"  "+ name +"SP"+sp); -                             } -                         } -                         if(Name! ="") -                         { -                             Continue; in                         } -                         foreach(stringSubkeyNameinchversionkey.getsubkeynames ()) to                         { +RegistryKey subkey =Versionkey.opensubkey (subkeyname); -Name = (string) Subkey.getvalue ("Version",""); the                             if(Name! ="") *SP = Subkey.getvalue ("SP",""). ToString (); $Install = Subkey.getvalue ("Install",""). ToString ();Panax Notoginseng                             if(Install = ="")//no install info, ust be later -Console.WriteLine (Versionkeyname +"  "+name); the                             Else +                             { A                                 if(sp! =""&& Install = ="1") the                                 { +Console.WriteLine ("  "+ SubkeyName +"  "+ name +"SP"+sp); -                                 } $                                 Else if(Install = ="1") $                                 { -Console.WriteLine ("  "+ SubkeyName +"  "+name); -                                 } the                             } -                         }Wuyi                     } the                 } -             } Wu}

Detecting the NETFramework version (excerpt) that the computer has installed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.