AnsweredAssumed Answered

vrf reading cpu time for a process

Question asked by g.nied on Mar 2, 2004
Stefan,

this task is not easy ...

You said that you already have the handle to the specified process (hProcess).

Then you need to make a call to
long __stdcall GetProcessTimes (long hProcess, int *lpCreationTime, int *lpExitTime, int *lpKernelTime, int *lpUserTime)

Take care that you have enough rights to your process handle!
The parameters are:

hProcess
An open handle that specifies the process whose timing information is sought. This handle must be created with PROCESS_QUERY_INFORMATION access. For more information, see Process Objects.

lpCreationTime
Points to a FILETIME structure that receives the creation time of the process.

lpExitTime
Points to a FILETIME structure that receives the exit time of the process. If the process has not exited, the content of this structure is undefined.

lpKernelTime
Points to a FILETIME structure that receives the amount of time that the process has executed in kernel mode. The time that each of the threads of the process has executed in kernel mode is determined, and then all of those times are summed together to obtain this value.

lpUserTime
Points to a FILETIME structure that receives the amount of time that the process has executed in user mode. The time that each of the threads of the process has executed in user mode is determined, and then all of those times are summed together to obtain this value.


Next you need to make some conversions to the times returned:
1) With
        long __stdcall FileTimeToLocalFileTime (int *lpFileTime, int *lpLocalFileTime)
   you convert the results from system file time to local file time
2) With
        long __stdcall FileTimeToSystemTime (int *lpFileTime, int *lpSystemTime)
   you connvert from (local) file time to (local) system time.

The VB declarations for these two time structures are:

Type FILETIME
        dwLowDateTime As Long
        dwHighDateTime As Long
End Type

Type SYSTEMTIME
    wYear As Integer
    wMonth As Integer
    wDayOfWeek As Integer
    wDay As Integer
    wHour As Integer
    wMinute As Integer
    wSecond As Integer
    wMilliseconds As Integer
End Type


This is just a collection of snippets, so if you have no clue how to glue *g* ask again.


best regards,

G. Nied

-------------------------------------------------------------------------
Georg Nied  - Software-Development - Hansestr.7 - 51149 Cologne - Germany
Tel: +49 2203 9770915 - Fax: +49 2203 9770924 - eMail:info@gn-software.de
-------------------------------------------------------------------------


To: s.feuerecker@bebro.de
    vrf@agilent.com


---
You are currently subscribed to vrf as: rsb@soco.agilent.com
To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com".
To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com".
To send messages to this mailing list,  email "vrf@agilent.com". 
If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com".

Outcomes