获取系统开机时间
来源:互联网 发布:巨人网络借壳参与企业 编辑:程序博客网 时间:2024/04/28 01:56
#include <stdio.h>
#include<ctime>
#include <windows.h>
using namespace std;
int main() {
time_t now;
struct tm when;
int tcount = GetTickCount();
time(&now);
when = *localtime(&now);
printf("现在时间为:%d年%d月%d日 %d:%d:%d/n", when.tm_year + 1900, when.tm_mon + 1,
when.tm_mday, when.tm_hour, when.tm_min, when.tm_sec);
now -= tcount / 1000;
when = *localtime(&now);
printf("开机时间为:%d年%d月%d日 %d:%d:%d/n", when.tm_year + 1900, when.tm_mon + 1,
when.tm_mday, when.tm_hour, when.tm_min, when.tm_sec);
DWORD dwStart = GetTickCount();
printf("%d/n", dwStart);
printf("已开机时间为 :%d天%d小时%d分钟%d秒/n", dwStart / (1000* 60* 60* 24 ) , dwStart%(1000*60*60*24)/(1000*60*60),dwStart%(1000*60*60*24)%(1000*60*60)/(1000*60),dwStart%(1000*60*60*24)%(1000*60*60)%(1000*60)/(1000));
return 0;
}
参考资料
如何在 C++ 程序中计算时间http://blog.csdn.net/linsi/archive/2010/04/22/5517210.aspx
- 获取系统开机时间
- java获取系统开机时间
- 获取系统开机和关机时间
- ios开发之获取系统开机时间
- Win8下获取系统开机时间
- iOS NSProcessInfo获取系统开机累计时间
- IOS NSProcessInfo获取系统开机累计时间
- android如何获取系统开机时间
- 获取系统信息,如开机时间,ram容量,等信息
- 如何获取开机时间
- 获取开机时间
- 获取开机时长与开机时间
- Android下获取开机时间
- C# 获取Windows开机时间
- 获取iOS设备开机时间
- Android下获取开机时间
- Linux查看系统开机时间
- Linux查看系统开机时间
- Zenoss学习杂记
- 什么是多态?为什么用多态?有什么好处?
- FireFox(FF)真强大
- asp.net - asp.net控件 - asp:Button
- 成功解决龙猫饲养的一大难题:乱撒尿
- 获取系统开机时间
- 物料搬运单(Move Order)
- Flex--读写本地文件 in Flash Player 10
- bug的生命周期
- C#中对word的一些操作
- treeView 加载子节点并显示加号
- javascript必备知识,让您对js的 function, javascript内置对象,this概念及之间的关系不再迷惑
- 关于tomcat6内存溢出myeclipse解决方法
- CodeForces Round#34 ABCD解题报告