On a Win10 PC, GetTickCount
is said to be reset to 0 at 0x9FFFFFF after 776 days. This is mentioned on Microsoft’s site:
GetTickCount resets to zero after approximately 776 days
Does timeGetTime()
have the same problem, too?
I tried to test as below, but I gave up because I couldn’t force the 776 days to change:
#include <iostream>
#include <windows.h>
#include <mmsystem.h>
int main() {
// 시작 시간 저장
DWORD startTime = GetTickCount();
DWORD startTime2 = timeGetTime();
LONGLONG startTime3 = GetTickCount64();
while (true)
{
// 현재 시간 저장
DWORD currentTime = GetTickCount();
DWORD currentTime2 = timeGetTime();
LONGLONG currentTime3 = GetTickCount64();
// 시간 차이 계산
DWORD diffTime = currentTime - startTime;
DWORD diffTime2 = currentTime2 - startTime2;
LONGLONG diffTime3 = currentTime3 - startTime3;
// 시간 출력
SYSTEMTIME st;
GetLocalTime(&st);
std::cout << "현재 날짜: " << st.wYear << "/" << st.wMonth << "/" << st.wDay << std::endl;
std::cout << "현재 시간: " << st.wHour << ":" << st.wMinute << ":" << st.wSecond << "." << st.wMilliseconds << std::endl;
std::cout << "GetTickCount("<< currentTime <<"(Days:"<< currentTime / 1000 / 3600 / 24 <<")" << ") 시간 차이: " << diffTime << " 밀리초" << std::endl;
std::cout << " GetTickCount64("<< currentTime3 <<"(Days:"<< currentTime3 / 1000 / 3600 / 24 << ")" <<") 시간 차이: " << diffTime3 << " 밀리초" << std::endl;
std::cout << " timeGetTime(" << currentTime2 <<"(Days:"<< currentTime2 / 1000 / 3600 / 24 << ")" << ") 시간 차이: " << diffTime2 << " 밀리초" << std::endl;
if ( diffTime > 20000 )
{
system("pause");
}
startTime = currentTime;
startTime2 = currentTime2;
startTime3 = currentTime3;
// 5초 대기
Sleep(5000);
}
system("pause");
return 0;
}
Please let me know if timeGetTime()
is not initialized to 0 at 0x9FFFFFF0 after 776 days.
Per C++ call to API function ::GetTickCount() jumps ~18 days, GetTickCount()
can be changed to GetTickCount64()
, but timeGetTime()
is being used because of the timer resolution, and I am wondering what to do.
이재호 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
7