Etichetă: c# windows version

Detect Windows Version in C#

This article has been written before more than 24months, information might old.

Cea mai cunoscuta modalitate sa determini versiunea windowsului este prin System.Environment.OSVersion mai jos este o functie care returneaza un string cu windowsul detectat .


using System;


       public static string azinfoos()
        {
            // Get OperatingSystem information from the system namespace.
            System.OperatingSystem osInfo = System.Environment.OSVersion;

            string azosver = "necunoscut";

            // Determine the platform.
            switch (osInfo.Platform)
            {
                // Platform is Windows 95, Windows 98,
                // Windows 98 Second Edition, or Windows Me.
                case System.PlatformID.Win32Windows:

                    switch (osInfo.Version.Minor)
                    {

                        case 0:
                            azosver = "Windows 95";
                            break;
                        case 10:
                            if (osInfo.Version.Revision.ToString() == "2222A")
                                azosver = "Windows 98 Second Edition";
                            else
                                azosver = "Windows 98";
                            break;
                        case 90:
                            azosver = "Windows Me";
                            break;
                    }
                    break;

                case System.PlatformID.Win32NT:

                    switch (osInfo.Version.Major)
                    {
                        case 3:
                            azosver ="Windows NT 3.51";
                            break;
                        case 4:
                            azosver = "Windows NT 4.0";
                            break;
                        case 5:
                            if (osInfo.Version.Minor == 0)
                                azosver = "Windows 2000";
                            else
                                azosver = "Windows XP";
                            break;
                        case 6:
                            azosver = "Windows Vista";
                            break;
                    } break;
            }
            return azosver;
        }