/**typedef union _LARGE_INTEGER {
struct {
DWORD LowPart;
LONG HighPart;
} DUMMYSTRUCTNAME;
struct {
DWORD LowPart;
LONG HighPart;
} u;
#endif //MIDL_PASS
LONGLONG QuadPart;
} LARGE_INTEGER;**///上边是LARGE_INTEGER的联合体声明,不用写,系统自己调用
int printTime(){
LARGE_INTEGER tick;
LARGE_INTEGER timestamp;
long time;
QueryPerformanceFrequency(&tick);
//QueryPerformanceFrequency函数得到你的计算机里高精度计时器每秒计时多少次,
//QueryPerformanceCounter函数得到当前计时器记了多少次.类似与GetTickCout.
QueryPerformanceCounter(×tamp);
int us=(timestamp.QuadPart % tick.QuadPart)*1E6/tick.QuadPart;//取微秒级的时间
/*us就是计算秒之后的时间*/
time = timestamp.QuadPart/tick.QuadPart;
int hours = time/3600;
time=time- (hours * 3600);
int minutes = time/60;
int seconds = time- (minutes * 60);
printf(
"系统已经启动了 %d小时%d分%d秒 %u微秒\n系统钟频%u, %uMHz\n",
hours, minutes, seconds,
us,
tick.LowPart,
tick.LowPart/1000000
);//打印当时的时间
return us,返回微秒级的时间,注意这里只返回的是秒以后的时间,并未返回准确的时间
}
将时间输出到微妙级别