Link to home
Start Free TrialLog in
Avatar of Sanjoo
Sanjoo

asked on

How do I programmatically find the CPU usage of another process in Windows NT & W2K?

How do I programmatically find the CPU usage of another process in Windows NT & W2K?
I want to delay my processing based on the CPU taken by a co-process. Both the processes are COM services.
Wondering how the Windows Task Manager or performance Manger does it!


Avatar of AlexVirochovsky
AlexVirochovsky

Avatar of Sanjoo

ASKER

Thanx, but..
I wanted to find the CPU usage of 'a particular process' at the current time and not the total CPU usage at the current time.(in Win NT & W2K) The CPU is of the Intel family of processors.

PS> I already have the Codepile.com stuff with me but it gives the total CPU usage only.

Or, you want for every thread. In such case see
http://www.edm2.com/0607/cpu.html
ASKER CERTIFIED SOLUTION
Avatar of AlexVirochovsky
AlexVirochovsky

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sanjoo

ASKER

That solution is only for OS/2 Warp I guess as the article goes. I wanted one that works for WinNT 4.0 and Win2K both!
I guess I mentioned it.

The article talks of only OS/2 Warp 3.0 and 4.0 nothing Microsoft about it!

Moreover I cannot use undocumented features in windows for the fear of future compatibilty.

Also, I am nearing on another different solution here, hopefully it should be over this week.

Thanks.
The information you want is in the performance counters of the system. There are API functions for reading this. Unfortunately they're not the most intuitive. There were some articles using performance counters recently in MSDN/MSJ magazine. Try searching the knowledge base at http://msdn.microsoft.com for information on reading performance counters. Incidentally you can also create your own counters if you have the need.

I'm sorry this isn't much help, but I haven't had the need yet to do this myself, so I don't know the specifics. But at least this should point you in the right direction.
Come to think of it, the articles I was thinking of were in Windows Developers Journal, but here are some similar articles from MSJ:

Part 1: general and for VB
http://www.microsoft.com/msj/defaultframe.asp?page=/msj/0398/hood0398.htm

and

Part 2: more specifics and for C/C++
http://www.microsoft.com/msj/defaultframe.asp?page=/msj/0598/hood0598.htm
If this proposed answer has helped you, please accept it, grade it and close this question.  If it is not, reject it and add comments as to your progress and what else is needed.

Thanks,
Moondancer
Community Support Moderator @ Experts Exchange
Zero response from Asker or expert(s) since my last follow up request, therefore can only assume that the Proposed Answer served the need.  Closing today.

I am sorry to see that Asker has not returned to update and finalize this question.  I am, therefore, force accepting this question.  In the event the Asker returns with additional needs related to this question, please respond and continue the collaboration process.
 
If there are questions in this regard, please comment and I'll return when I can.
 
The HELP DESK link on the left is informative, and includes this site's Guidelines and Member Agreement as well as assistance related to Questions and Answers.  Here is the QA link, as a reference.
 
https://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp

--->  While I'm here anyway, letting all know that we have added quite a number of new Topic Areas, as you'll see from the link below:

https://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thank you,
Moondancer
Community Support Moderator @ Experts Exchange