GetTickCount64不可靠

时间:2024-11-20 07:13:19

GetTickCount有重置为0的问题,所以用GetTickCount64,在xp下用函数代替GetTickCount64

inline __int64 _GetSysTickCount64()
	{
		LARGE_INTEGER TicksPerSecond = { 0 };
		LARGE_INTEGER Tick;
		if (!)
			QueryPerformanceFrequency(&TicksPerSecond);
		QueryPerformanceCounter(&Tick);
		__int64 Seconds =  / ;
		__int64 LeftPart =  - (*Seconds);
		__int64 MillSeconds = LeftPart * 1000 / ;
		__int64 Ret = Seconds * 1000 + MillSeconds;
		return Ret;
	};

程序运行3天后发现,测试发现,

__int64 d0 = GetTickCount64();
__int64 d1 = _GetSysTickCount64();
cout <<d0 << ":" << d1 << "*" << (d0-d1) << endl;

GetSysTickCount64 和 GetSysTickCount64 同一时刻差距很大真是奇葩啊。看来
GetSysTickCount64 不能用于校时标准了。