■ OperatingSystem 클래스를 사용해 운영체제명을 구하는 방법을 보여준다.
▶ Program.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
namespace TestProject; /// <summary> /// 프로그램 /// </summary> class Program { //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Static //////////////////////////////////////////////////////////////////////////////// Private #region 운영체제명 구하기 - GetOperatingSystemName(platformID, majorVersion, minorVersion) /// <summary> /// 운영체제명 구하기 /// </summary> /// <param name="platformID">플랫폼 ID</param> /// <param name="majorVersion">메이저 버전</param> /// <param name="minorVersion">마이너 버전</param> /// <returns>운영체제명</returns> private static string GetOperatingSystemName(PlatformID platformID, int majorVersion, int minorVersion) { if(platformID == PlatformID.Win32NT) { if(majorVersion == 4) { if(minorVersion == 0) { return "Windows NT 4.0"; } } else if(majorVersion == 5) { if(minorVersion == 0) { return "Windows 2000"; } else if(minorVersion == 1) { return "Windows XP"; } } else if(majorVersion == 6) { if(minorVersion == 0) { return "Windows Vista"; } else if(minorVersion == 1) { return "Windows 7"; } else if(minorVersion == 2) { return "Windows 8"; } else if(minorVersion == 3) { return "Windows 8.1"; } } else if(majorVersion == 10) { if(minorVersion == 0) { return "Windows 10"; } } } return null; } #endregion #region 프로그램 시작하기 - Main() /// <summary> /// 프로그램 시작하기 /// </summary> private static void Main() { OperatingSystem operatingSystem = Environment.OSVersion; PlatformID platformID = operatingSystem.Platform; int majorVersion = operatingSystem.Version.Major; int minorVersion = operatingSystem.Version.Minor; Console.WriteLine($"플랫폼 ID : {platformID }"); Console.WriteLine($"메이저 버전 : {majorVersion}"); Console.WriteLine($"마이너 버전 : {minorVersion}"); Console.WriteLine($"운영체제명 : {GetOperatingSystemName(platformID, majorVersion, minorVersion)}"); } #endregion } |