API都会调用,放这个例子上来是想说一下程序运行时间,内核时间以及用户时间是怎么一回事。
部分关键的代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
GetProcessTimes(hProcess, &ftCreation, &ftExit, &ftKernel, &ftUser); timeCreation = ftCreation; strData.Format("Created at %02d:%02d:%02d", timeCreation.GetHour(), timeCreation.GetMinute(), timeCreation.GetSecond()); timeDiff = timeNow - timeCreation; strData.Format("Elapsed time = %ud %uh %um %us", timeDiff.GetDays(), timeDiff.GetHours(), timeDiff.GetMinutes(), timeDiff.GetSeconds()); FileTimeToSystemTime(&ftKernel, &stKernel); strData.Format("Time in kernel mode = %uh %um %us", stKernel.wHour, stKernel.wMinute, stKernel.wSecond); |
下载 [download id=”17″]
via codeproject.com
-EOF-