views:

163

answers:

1

I want to be able to get the current % CPU usage in a C++ program running under Wince.

I found this link that states where the source code is but I cannot find it in my platform builder installation - I expect this is because it isn't the Windows Automotive platform.

Does anyone know where I can find this source code or (even better) know how I can get this information directly? i.e. what DLL / function calls to make etc.

+3  A: 

Since GetProcessTimes doesn't exist in CE, you have to calculate this.

You have to start with the toolhelp APIs to enumerat the processes and the threads in the processes. You tehn call GetThreadTimes for each thread and add all that up.

Bear in mind that the act of calculating this info will affect the CPU utilization.

ctacke
Hi thanks for the responsve. I think I may have been a little ambiguous in my question. What I am really looking for is a way to get % CPU usage times. How can I find this out?
Chris
Just like the top.exe application, you have to calculate it. The way to do that is to iterate through all threads in all processes and add up all of the thread times then divide the time it took to calculate by that amount.
ctacke