- Windows Processes and Threads
- Process Creation
- Process Identities
- Duplicating Handles
- Exiting and Terminating a Process
- Waiting for a Process to Terminate
- Environment Blocks and Strings
- Example: Parallel Pattern Searching
- Processes in a Multiprocessor Environment
- Process Execution Times
- Example: Process Execution Times
- Generating Console Control Events
- Example: Simple Job Management
- Example: Using Job Objects
- Summary
- Exercises
Process Execution Times
You can determine the amount of time that a process has consumed (elapsed, kernel, and user times) using the GetProcessTimes function.
BOOL GetProcessTimes ( HANDLE hProcess, LPFILETIME lpCreationTime, LPFILETIME lpExitTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime) |
The process handle can refer to a process that is still running or to one that has terminated. Elapsed time can be computed by subtracting the creation time from the exit time, as shown in the next example. The FILETIME type is a 64-bit item; create a union with a LARGE_INTEGER to perform the subtraction.
Chapter 3's lsW example showed how to convert and display file times, although the kernel and user times are elapsed times rather than calendar times.
GetThreadTimes is similar and requires a thread handle for a parameter.