Total CPU usage %

Hi Guys,

Would you please help to figure out which API structure can provide the total CPU usage(as percentage %) for Windows 7 similar to the one shown the Task manager?

I found some example but tend to be complex calculations to calculate individual process then come up with the total.

WMI is not required if you are not familiar to COM. This is an alternative solution:
The "NtQuerySystemInformation()" function is undocumented? Someone should probably tell Microsoft then:
Yes, it's "undocumented", despite a page being available for it.

The first thing on the page is:
[NtQuerySystemInformation may be altered or unavailable in future versions of Windows. Applications should use the alternate functions listed in this topic.]
That to me says "unsupported" which is a little different. There are plenty of functions in the WinAPI that are truly undocumented. Here is a partial list of some of them:

Maybe I'm just splitting hairs but unsupported means they plan on replacing the function eventually where as undocumented means you probably shouldn't use that function at all.
Maybe I'm just splitting hairs but ...
Yes, I think you're splitting hairs.
You can use GetSystemTimes() APi instead of NtQuerySystemInformation if you want to use only documented APIs. You will get the same information.

Example code:
Topic archived. No new replies allowed.