有关window编程多线程
这是Windows核心编程中的例子,我照打了一遍,就是添加了需要测试的任务(sleep(1000)),为什么输出结果都是0?求请教.__int64 FileTimeToQuadWord(PFILETIME pft)
{
return (Int64ShllMod32(pft->dwHighDateTime,32)| pft->dwLowDateTime);
}
void GetTaskTime()
{
FILETIME ftKernelTimeStart,ftKernelTimeEnd;
FILETIME ftUserTimeStart,ftUserTimeEnd;
FILETIME ftDummy;
__int64 qwKernelTimeElapsed,qwUserTimeElapsed,qwTotalTimeElapsed;
GetThreadTimes(GetCurrentThread(),&ftDummy,&ftDummy,&ftKernelTimeStart,&ftUserTimeStart);
//执行的任务
Sleep(1000);
GetThreadTimes(GetCurrentThread(),&ftDummy,&ftDummy,&ftKernelTimeEnd,&ftUserTimeEnd);
qwKernelTimeElapsed=FileTimeToQuadWord(&ftKernelTimeEnd)-FileTimeToQuadWord(&ftKernelTimeStart);
qwUserTimeElapsed=FileTimeToQuadWord(&ftUserTimeEnd)-FileTimeToQuadWord(&ftUserTimeStart);
qwTotalTimeElapsed=qwKernelTimeElapsed+qwUserTimeElapsed;
_tprintf(_T("kernel: %d,uer: %d, the total time elapsed is: %d"),qwKernelTimeElapsed,qwUserTimeElapsed,qwTotalTimeElapsed);
}
int _tmain(int argc, _TCHAR* argv[])
{
GetTaskTime();
system("pause");
return 0;
}