기본 콘텐츠로 건너뛰기

VS 2017:C++에서 timeGetTime() 과 GetTickCount() 결과값 비교(DWORD 로 같은 내용 반환)

// timeGetTime() 과 GetTickCount() 다른 내용인 것 처럼 표시되어 있으나,
// 적어도, VS2017 에서는 같은 결과를 반납함. 
// 혹시, 다른 버전에서는 다른 결과를 반납하는지 확인 필요.

#include <iostream>
#include <string>
#include <windows.h> // GetTickCount()
#pragma comment(lib, "winmm.lib") // timeGetTime()
using DWORD = unsigned long;
int main()
{
const DWORD curTime2 = timeGetTime();
std::cout << "timeGetTime(): " << curTime2 << std::endl;

const DWORD curTime = GetTickCount(); //49.5일에 초기화문제 있슴. ULONGLONG GetTickCount64() 를 쓰는 것도 검토 해볼만함
std::cout << "GetTickCount(): " << curTime << std::endl;

std::cout << "Press enter a key." << std::endl;
std::getchar();
return 0;
}

실행 결과
timeGetTime(): 15419953
GetTickCount(): 15419953
Press enter a key.

댓글