void GetBootTimeDetails() { time_t lt; lt =time(NULL); //GetTickcount函数:它返回从操作系统启动到当前所经过的毫秒数,常常用来判断某个方法执行的时间,其函数原型是DWORD GetTickCount(void),返回值以32位的双字类型DWORD存储,因此可以存储的最大值是(2^32-1) ms约为49.71天,因此若系统运行时间超过49.71天时,这个数就会归0,增加一个静态变量坐下判断即可 __int64 TickCount = GetTickCount(); __int64 diff = lt - TickCount/1000; if(diff < 0) { return; } struct tm local; local = *localtime(&diff); m_sdata = to_string(local.tm_year+1900) + '-' + to_string(local.tm_mon+1) + '-' + to_string(local.tm_mday) + ' ' +to_string(local.tm_hour) + ':' + to_string(local.tm_min) + ':' + to_string(local.tm_sec); }
获取开机自启动时间
最新推荐文章于 2023-02-15 16:03:13 发布