Click to See Complete Forum and Search --> : How do we get CPU Usage?


Deniz
December 15th, 2004, 05:19 PM
In XP you get the Task Manager and in the Performance tab it has CPU usage.

Does anyone know how to get the CPU usage percentage using VC++?

Andreas Masur
December 16th, 2004, 03:56 AM
CPU usage in terms of time or percentage? For the former one you can use GetProcessTimes() (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/getprocesstimes.asp)...for the latter one NtQuerySystemInformation (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/ntquerysysteminformation.asp)....

Note, that 'NtQuerySystemInformation()' does only work on systems NT or higher...

Deniz
December 16th, 2004, 04:42 PM
Thank you Andreas.

Andreas Masur
December 17th, 2004, 03:50 AM
You are welcome...