[C#] PC 환경 정보(CPU,Memory,HDD) 가져오기

윈도우 환경에서 개발을 하다보면 CPU점유율 정보와 메모리 사용률에 따라 로직을 구현해야 하는경우가 발생한다. 
여기서는 CPU 와 메모리 상태정보, HDD용량정보를 가져오는 방법에 대해 알아보자.

➤ CPU 정보 가져오기

PerformanceCounter cpuload = new PerformanceCounter("Processor", "% Processor Time",​ "_Total"​);
cpuLoad.NextValue();

➤ Memory 정보 가져오기 (사용가능용량)

PerformanceCounter momoryload = new PerformanceCounter("Memory", "Available MBytes"​);
memoryLoad.NextValue(); 

➤ HDD 용량 정보

DriveInfo[] diDrives = DriveInfo.GetDrives();
diDrives[i].TotalSize; // 전체용량
diDrives[i].TotalFreeSpace; // 사용가능 용량



댓글