一 引言
有时候,在windows程序中,需要高精度的时间,比如ms级。
这时,可以使用GetTickCount函数。
二 做法
调用函数需包含windows.h。得到的是系统运行的时间,精确到毫秒,测试程序如下:
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
double start = GetTickCount();
Sleep(1000);
double end = GetTickCount();
cout << "GetTickCount:" << end-start << endl;
return 0;
}