Process CPU Time

delphi package - easy access to kernel objects etc.
Post Reply
Mazinger
Posts: 33
Joined: Wed Jan 26, 2005 6:26 am

Process CPU Time

Post by Mazinger »

Hi,

I need to know the % CPU is using a process (like the taskbar).
How can I do it?

Thanks in advance.
madshi
Site Admin
Posts: 10365
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Hello,

sorry for the late reply.

There are 2 possibilities for doing this: You can get access to the OS's performance counters. That's quite ugly to do, but works. Alternatively you can use "GetProcessTimes" (or "IProcess.GetTimes"). Call this twice with a delay in between and then you can see the difference between the reported times and calculate the CPU consumption from that information.
Post Reply