我希望能够说出从开机到启动 Windows 需要多长时间。有没有办法追溯确定(即一旦窗口启动)?BIOS/CMOS 是否保持上次启动时间?是否可以从 RDTSC 中得知机器运行了多长时间并减去 Windows 启动时间?
问问题
767 次
2 回答
0
从 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));
}
于 2010-11-06T21:42:43.623 回答