简体   繁体   中英

How do I determine sub versions of Windows 7 programatically in C#?

I need to determine whether a machine is running Windows 7 Pro, or Windows 7 Embedded. Environment.OSVersion returns the same version number on both systems, as does the Windows Management Interface. I'm looking at the Registry for some form of identifier, but I'm wondering if there is a solution I haven't considered yet.

Run the above code to get the OS details:

  using System;

    public class Example
    {
        public static void Main()
        {
            var os = Environment.OSVersion;
            Console.WriteLine("Current OS Information:\n");
            Console.WriteLine("Platform: {0:G}", os.Platform);
            Console.WriteLine("Version String: {0}", os.VersionString);
            Console.WriteLine("Version Information:");
            Console.WriteLine("   Major: {0}", os.Version.Major);
            Console.WriteLine("   Minor: {0}", os.Version.Minor);
            Console.WriteLine("Service Pack: '{0}'", os.ServicePack);
            Console.ReadKey();
        }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM