比如两个时间:
CString t1="2007/11/09 17:42:10.466"
CString t2="2007/11/09 17:42:11.287"
这样做的:
SYSTEMTIME tS,tE;
tS.wYear = nYear1;
tS.wMonth = nMonth1;
tS.wDay = nDate1;
tS.wHour = nHour1;
tS.wMinute = nMin1;
tS.wSecond = nSec1;
tS.wMilliseconds = nMilliSec1;
tE.wYear = nYear2;
tE.wMonth = nMonth2;
tE.wDay = nDate2;
tE.wHour = nHour2;
tE.wMinute = nMin2;
tE.wSecond = nSec2;
tE.wMilliseconds = nMilliSec2;
ULARGE_INTEGER fTime1;/*FILETIME*/
ULARGE_INTEGER fTime2;/*FILETIME*/
SystemTimeToFileTime(&tS,(FILETIME*)&fTime1);
SystemTimeToFileTime(&tE,(FILETIME*)&fTime2);
CString sTimeMilli;
sTimeMilli.Format("%d",(fTime2.QuadPart - fTime1.QuadPart)/10000);
本文介绍了一种使用Windows API函数SystemTimeToFileTime来计算两个具体时间点之间的毫秒级差值的方法。通过将CString类型的时间字符串转换为SYSTEMTIME结构,再进一步转换成FILETIME格式,最后计算出两个时间点之间的差值。
639

被折叠的 条评论
为什么被折叠?



