如何获得系统化时间

ncustlyh 2005-01-10 10:52:01
把上次打开程序的时间记录下来,下次再打开程序时的时间减去上次打开程序的时间,求两个时间的差值,好做么?希望能帮帮小弟!!!
...全文
81 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
老夏Max 2005-01-14
  • 打赏
  • 举报
回复
软件已经打包,那还求什么啊,呵呵!
ncustlyh 2005-01-14
  • 打赏
  • 举报
回复
希望得到的效果是:上次关闭该软件的时间,现在打开该软件的时间,两个时间的时间差怎么来求?(当然还是要在源代码里面实现了)希望能得到更多的支持,小弟谢谢大家了!!!
ncustlyh 2005-01-13
  • 打赏
  • 举报
回复
该程序已经打包,运行该打包后的软件。希望得到的效果是:上次关闭该软件的时间,现在打开该软件的时间,两个时间的时间差怎么来求?希望能得到更多的支持,小弟谢谢大家了!!!
老夏Max 2005-01-10
  • 打赏
  • 举报
回复
注意时间差为CTimeSpan类对象,其提供了
GetDays —— Returns the number of complete days in this CTimeSpan.
GetHours —— Returns the number of hours in the current day (–23 through 23).
GetTotalHours —— Returns the total number of complete hours in this CTimeSpan.
GetMinutes —— Returns the number of minutes in the current hour (–59 through 59).
GetTotalMinutes —— Returns the total number of complete minutes in this CTimeSpan.
GetSeconds —— Returns the number of seconds in the current minute (–59 through 59).
GetTotalSeconds —— Returns the total number of complete seconds in this CTimeSpan.
这些函数用于获得时间的差值!
老夏Max 2005-01-10
  • 打赏
  • 举报
回复
直接使用加减,参考:
// example for CTime::operator +, -
CTime t1( 1999, 3, 19, 22, 15, 0 ); // 10:15PM March 19, 1999
CTime t2( 1999, 3, 20, 22, 15, 0 ); // 10:15PM March 20, 1999
CTimeSpan ts = t2 - t1; // Subtract 2 CTimes
ASSERT( ts.GetTotalSeconds() == 86400L );
ASSERT( ( t1 + ts ) == t2 ); // Add a CTimeSpan to a CTime.
ASSERT( ( t2 - ts ) == t1 ); // Subtract a CTimeSpan from a Ctime
ipgk 2005-01-10
  • 打赏
  • 举报
回复
用GetSystemTimeAsFileTime获取当前时间,用CompareFileTime比较时间。
xuzheng318 2005-01-10
  • 打赏
  • 举报
回复
1.定义一个全局变量,保存你初始化时得到的系统时间 init_time;
2.用clock()得到你的程序运行了多少时间;
3.init_time+clock()和系统时间进行比较,就能知道更改了多少.

至于系统时间被更改后,重新初始化完毕,之后如何判断又被更改的时间,那就在设一个变量,记录之前更改量,修正init_time+clock(),之后就一样了。

这是一个基本思路吧,具体看你的需要来写程序,相信能解决。
oyljerry 2005-01-10
  • 打赏
  • 举报
回复
GetFileTime获得文件时间信息
GetCurrentTime获得当前时间

2,640

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 硬件/系统
社区管理员
  • 硬件/系统社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧