redforce
asked on
How to handle FileTime format
I want to use the API function GetProcessTimes. I send all running processes to that funktion and want to know the CPUusage.
The problem is that getprocesstimes uses the Filetime Format. I dont know how to handle it. I need a formula that changes the value to percentages.
I use following to get the values:
var
PH:THandle;
CreationTime, ExitTime, KernelTime, UserTime: FileTime;
i: integer;
begin
for i:=1 to numberofprocesses do begin
GetProcessTimes(PH, CreationTime, ExitTime, KernelTime, UserTime);
.... //Here a need the formula
I know the number of processes, but I don't know how to handle the values.
Could you help me about the formula to convert the values to get percentages?
My system has two CPUs. I like to view the usage for both CPUs seperatly.
The problem is that getprocesstimes uses the Filetime Format. I dont know how to handle it. I need a formula that changes the value to percentages.
I use following to get the values:
var
PH:THandle;
CreationTime, ExitTime, KernelTime, UserTime: FileTime;
i: integer;
begin
for i:=1 to numberofprocesses do begin
GetProcessTimes(PH, CreationTime, ExitTime, KernelTime, UserTime);
.... //Here a need the formula
I know the number of processes, but I don't know how to handle the values.
Could you help me about the formula to convert the values to get percentages?
My system has two CPUs. I like to view the usage for both CPUs seperatly.
hi redforce,
you can transform the filetime with the api function FiletimeToSystemtime (or similar) to Systemtimeformat, then delphi has a function, if needed, SystemtimeToDateTime to transform Systemtime to Datetimeformat. let me know if you need a sample
meikl
you can transform the filetime with the api function FiletimeToSystemtime (or similar) to Systemtimeformat, then delphi has a function, if needed, SystemtimeToDateTime to transform Systemtime to Datetimeformat. let me know if you need a sample
meikl
ASKER
An example wouldn't be bad. I've changed format to double with these functions. but I dont know how to use these values to get to the used Systemtime.
I've got the following formula. (I don't know if it works)
(lpkerneltime + lpusertime) div (number of processors * lpcreationtime - lpexittime)
All values are from getprocesstimes()
I've got the following formula. (I don't know if it works)
(lpkerneltime + lpusertime) div (number of processors * lpcreationtime - lpexittime)
All values are from getprocesstimes()
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
redforce, are you here?
ASKER
Sorry meikl, weekend ... I was away.
I tried your corversation function and it works.
You get the points.
But by the way: the values I get when running the formula couldn't be right.
something vith 4194629. A little worse isn't it? Do you think the formula is right? The funniest thing: the value changes only if I start a new process (4194629 - 1). This can't be the right formula to view the actuel CPU Usage.
Do you know the solution?
I tried your corversation function and it works.
You get the points.
But by the way: the values I get when running the formula couldn't be right.
something vith 4194629. A little worse isn't it? Do you think the formula is right? The funniest thing: the value changes only if I start a new process (4194629 - 1). This can't be the right formula to view the actuel CPU Usage.
Do you know the solution?
hi redforce,
well, i never looked at the api-call u use,
but i will take a closer look to it.
this can take a bit time,
because it becomes night here.
dont worry about the values,
because the datetime-typ counts at 31.12.1899.
i leave this q open,
maybe i can provide a working sample.
until then
meikl
well, i never looked at the api-call u use,
but i will take a closer look to it.
this can take a bit time,
because it becomes night here.
dont worry about the values,
because the datetime-typ counts at 31.12.1899.
i leave this q open,
maybe i can provide a working sample.
until then
meikl
ASKER