728x90
Environment 클래스에는 앱이 실행되는 시스템을 설명하는 데 도움이 되는 다양한 속성이 있습니다.
다음은 인라인 주석이 있는 몇 가지 예입니다.
- 내 PC는 64비트 OS이므로 true를 반환합니다.
- 컴퓨터 이름을 반환합니다. 제 경우에는 ANDRAS1입니다.
- 운영 체제 버전, 빌드, 메이저, 마이너 등에 대한 정보를 반환합니다.
- 플랫폼 ID를 열거형으로 반환합니다. 제 경우에는 Win32NT입니다.
- 현재 설치된 서비스 팩, 내 경우에는 서비스 팩 1
- OS의 toString 버전, 이 PC의 "Microsoft Windows NT 6.1.7601 서비스 팩 1"입니다.
- 이 PC에는 4개의 프로세서가 있습니다.
- 2개의 논리 드라이브 반환: C: 및 D:
- 이것은 시스템의 모든 환경 변수를 찾고 이를 통해 반복하는 방법입니다.
- 현재 CLR 버전을 검색합니다. 제 경우에는 "4.0.30319.18444"입니다.
//returns true on my PC as it is a 64-bit OS
bool is64BitOperatingSystem = Environment.Is64BitOperatingSystem;
//returns the machine name, in my case ANDRAS1
string machineName = Environment.MachineName;
//returns information about the operating system version, build, major, minor etc.
OperatingSystem os = Environment.OSVersion;
//returns the platform id as an enumeration, in my case it's Win32NT
PlatformID platform = os.Platform;
//the currently installed service pack, Service Pack 1 in my case
string servicePack = os.ServicePack;
//the toString version of the OS, this is "Microsoft Windows NT 6.1.7601 Service Pack 1" on this PC
string version = os.VersionString;
//I have 4 processors on this PC
int processorCount = Environment.ProcessorCount;
//returns 2 logical drives: C: and D:
string[] logicalDrives = Environment.GetLogicalDrives();
//this is how to find all environmental variables of the system and iterate through them
IDictionary envVars = Environment.GetEnvironmentVariables();
foreach (string key in envVars.Keys)
{
//e.g. the JAVA_HOME env.var is set to "C:\Progra~1\Java\jdk1.7.0_51\"
Debug.WriteLine(string.Concat("key: ", key, ": ", envVars[key]));
}
//retrieve the current CLR version, in my case it's "4.0.30319.18444"
Version clrVersion = Environment.Version;
여기에서 진단과 관련된 모든 게시물을 볼 수 있습니다.
728x90
'프로그래밍' 카테고리의 다른 글
[C++] WMI - OS의 모든 것을 질의 해보기 (0) | 2023.02.07 |
---|---|
[C#] 텍스트 파일 읽기 (0) | 2023.02.06 |
[C#.NET] 모든 WMI 클래스 속성 찾아내기 (0) | 2023.02.04 |
[C/C++]sizeof 사용 없이 배열의 sizeof 찾기 (0) | 2023.01.29 |
[C#] quartz 모듈 사용하기 (0) | 2023.01.28 |