본문 바로가기
1.개발/1.C#

[C#] OS버젼 알아내기

by 벅스쭌 2010. 12. 24.


        private string getOsVersion()
        {
            OperatingSystem os = Environment.OSVersion;

            switch (os.Platform)
            {
                //windows95이상
                case PlatformID.Win32Windows:
                    if (os.Version.Major == 4)
                    {
                        switch (os.Version.Minor)
                        {
                            case 0: osVersion = "Windows95"; break;
                            case 10: osVersion = "Windows98"; break;
                            case 90: osVersion = "WindowsMe"; break;
                        }
                    }
                    break;

                //windowsNT이상
                case PlatformID.Win32NT:
                    if (os.Version.Major == 4)
                    {
                        osVersion = "WindowsNT";
                    }
                    else if (os.Version.Major == 5)
                    {
                        switch (os.Version.Minor)
                        {
                            case 0:
                                osVersion = "WindowsServer2000";break;
                            case 1: osVersion = "WindowsXP"; break;
                            case 2: osVersion = "WindowsServer2003"; break;
                        }
                    }
                    else if (os.Version.Major == 6)
                    {
                        switch (os.Version.Minor)
                        {
                            case 0: osVersion = "WindowsServer2008"; break;
                            case 1: osVersion = "Windows7"; break;
                        }
                    }
                    break;
                //
                case PlatformID.WinCE://windowsCE
                    if (os.Version.Major == 0)
                    {

                    }
                    break;
            }
            return osVersion;
        }

반응형

댓글0