计算2个SYSTEMTIME的时间差

MFC版本的计算两个SYSTEMTIME之间的时间差,返回毫秒:

__int64 TimeDiff(SYSTEMTIME left, SYSTEMTIME right)  
{
	CTime tmLeft(left.wYear, left.wMonth, left.wDay, 0, 0, 0);
	CTime tmRight(right.wYear, right.wMonth, right.wDay, 0, 0, 0);
	
	CTimeSpan sp = tmLeft - tmRight;
	long MillisecondsL = (left.wHour*3600 + left.wMinute*60 + left.wSecond)*1000 + left.wMilliseconds;  
	long MillisecondsR = (right.wHour*3600 + right.wMinute*60 + right.wSecond)*1000 + right.wMilliseconds;  

	return  (__int64)sp.GetDays()*86400000 + (MillisecondsL - MillisecondsR);//此处返回毫秒
}


你可能感兴趣的:(SYSTEMTIME)