
윈도우즈 NT계열, 2000등 이상에서 사용가능합니다.
pdh.dll을 사용하구요.
Performance Monitor - Get System Counter Values (CPU, Memory, etc.)
--------------------------------------------------------------------------------
This article was contributed by Mike Ryan.
Environment: VC6, Windows 2000, Windows NT 4.0 SP3
Note: This article is specific to Windows 2000 and Windows NT 4.0 SP3+. It does not support Windows 95 or 98. For Windows NT 4, you will need PDH.DLL and PDH.LIB which are not supplied with the OS.
I wrote this code because I couldn't find any good resource meters for Windows 2000. Plenty of them exist for Windows 95/98 and I figured that I might as well write my own.
I have wrapped the PDH into a nice C++ class called CPerfMon. It will support all the counters available under Windows. I have done some predefined timers for easy use. These are as follows:
// % of cpu in use
#define CNTR_CPU "\\Processor(_Total)\\% Processor Time"
// mem in use measured in bytes
#define CNTR_MEMINUSE_BYTES "\\Memory\\Committed Bytes"
// mem available measured in bytes
#define CNTR_MEMAVAIL_BYTES "\\Memory\\Available Bytes"
// mem avail in kilobytes
#define CNTR_MEMAVAIL_KB "\\Memory\\Available KBytes"
// mem avail in megabytes
#define CNTR_MEMAVAIL_MB "\\Memory\\Available MBytes"
// % of mem in use
#define CNTR_MEMINUSE_PERCENT "\\Memory\\% Committed Bytes In Use"
// commit limit on memory in bytes
#define CNTR_MEMLIMIT_BYTES "\\Memory\\Commit Limit"
위의 정의된 쿼리말고도 MSDN 찾아보면 더 많은걸 할 수 있습니다.