【发布时间】:2011-05-05 20:35:23
【问题描述】:
我想知道从开机到 Windows 启动需要多长时间。 有没有办法追溯确定(即一旦窗口启动)? BIOS/CMOS 是否保持上次启动时间? 是否可以从 RDTSC 中得知机器运行了多长时间并减去 Windows 启动时间?
【问题讨论】:
我想知道从开机到 Windows 启动需要多长时间。 有没有办法追溯确定(即一旦窗口启动)? BIOS/CMOS 是否保持上次启动时间? 是否可以从 RDTSC 中得知机器运行了多长时间并减去 Windows 启动时间?
【问题讨论】:
从 GetTickCount() 获取开机后的时间。然后获取 Windows 在启动时接触的文件的时间戳(例如 windows\bootstat.dat)。代码如下。在我的机器上它说 16 秒,这听起来很准确。
#include <stdio.h>
#include <windows.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
int main()
{
struct __stat64 st;
_stat64("c:\\windows\\bootstat.dat", &st);
return printf("%d\n", st.st_mtime - (time(NULL) - GetTickCount()/1000));
}
【讨论】:
【讨论】: