[C#/COMMON] Environment 클래스 : OSVersion 정적 속성을 사용해 Windows 운영 체제 버전 구하기
C#/Common 2012. 11. 22. 08:17728x90
반응형
728x170
■ Environment 클래스의 OSVersion 정적 속성을 사용해 Windows 운영 체제 버전을 구하는 방법을 보여준다.
▶ 예제 코드 (C#)
using System;
/// <summary>
/// 운영 체제 타입
/// </summary>
public enum OperatingSystemType
{
Unknown ,
Windows95 ,
Windows98 ,
WindowsMe ,
WindowsNT40 ,
WindowsNT2000 ,
WindowsXP ,
WindowsServer2003,
WindowsVista ,
Windows7
}
#region 운영 체제 타입 구하기 - GetOperatingSystemType()
/// <summary>
/// 운영 체제 타입 구하기
/// </summary>
/// <returns>운영 체제 타입</returns>
public OperatingSystemType GetOperatingSystemType()
{
OperatingSystem operatingSystem = Environment.OSVersion;
OperatingSystemType operatingSystemType = OperatingSystemType.Unknown;
switch(operatingSystem.Platform)
{
case PlatformID.Win32Windows :
if(operatingSystem.Version.Major == 4)
{
switch(operatingSystem.Version.Minor)
{
case 0 : operatingSystemType = OperatingSystemType.Windows95; break;
case 10 : operatingSystemType = OperatingSystemType.Windows98; break;
case 90 : operatingSystemType = OperatingSystemType.WindowsMe; break;
}
}
break;
case PlatformID.Win32NT :
if(operatingSystem.Version.Major == 4)
{
operatingSystemType = OperatingSystemType.WindowsNT40;
}
else if(operatingSystem.Version.Major == 5)
{
switch(operatingSystem.Version.Minor)
{
case 0 : operatingSystemType = OperatingSystemType.WindowsNT2000; break;
case 1 : operatingSystemType = OperatingSystemType.WindowsXP; break;
case 2 : operatingSystemType = OperatingSystemType.WindowsServer2003; break;
}
}
else if(operatingSystem.Version.Major == 6)
{
switch(operatingSystem.Version.Minor)
{
case 0 : operatingSystemType = OperatingSystemType.WindowsVista; break;
case 1 : operatingSystemType = OperatingSystemType.Windows7; break;
}
}
break;
}
return operatingSystemType;
}
#endregion
728x90
반응형
그리드형(광고전용)
'C# > Common' 카테고리의 다른 글
[C#/COMMON] String 클래스 : Format 메소드 사용하기 (0) | 2014.03.11 |
---|---|
[C#/COMMON] XmlTextReader 클래스 : XML 데이터 읽기 (0) | 2014.03.11 |
[C#/COMMON] 이벤트 핸들러 : 익명 Delegate/Linq 람다식 대체하기 (0) | 2014.01.31 |
[C#/COMMON] Enum 클래스 : 문자열로 멤버 값 구하기 (0) | 2014.01.29 |
[C#/COMMON] 다각형 꼭지점 리스트 구하기 (0) | 2013.12.28 |
[C#/COMMON] ManagedInstallerClass 클래스 : InstallHelper 정적 메소드를 사용해 윈도우즈 서비스 설치하기 (0) | 2012.12.02 |
[C#/COMMON] Beep 음 발생시키기 (0) | 2012.10.08 |
[C#/COMMON] SqlConnection 클래스 : GetSchema 메소드를 사용해 SQL Server 데이타베이스 리스트 가져오기 (0) | 2012.10.06 |
[C#/COMMON] 숫자 포맷 문자열 사용하기 (0) | 2012.09.29 |
[C#/COMMON] DefaultValueAttribute 클래스 : 속성 디폴트 값 설정하기 (0) | 2011.11.16 |
댓글을 달아 주세요