在几台 Windows 计算机上,我看到两个相互跟随的对 ::GetTickCount() 的调用返回 1610619236 毫秒(大约 18 天)的差异。这不是因为环绕 og int/unsigned int 不匹配。我使用 Visual C++ 2015/2017。
有没有其他人看到过这种行为?有没有人知道什么可能导致这样的行为?
最好的问候约翰
显示错误的代码示例:
class CLTemp
{
DWORD nLastCheck;
CLTemp()
{
nLastCheck=::GetTickCount();
}
//Service is called every 200ms by a timer
void Service()
{
if( ::GetTickCount() - nLastCheck > 20000 )//check every 20 sec
{
//On some Windows machines, after an uptime of 776 days, the
//::GetTickCount() - nLastCheck gives a value of 1610619236
//(corresponding to around 18 days)
nLastCheck = ::GetTickCount();
}
}
};