简单问题,怎样初始化一个CTime? 我编一个程序需要搜索创建时间最早的文件,我用一个CTime变量time来表示所搜索到的文件的最早创建时间,这个值应该初始化成比任何文件创建的时间更早的值。我现在不知道如何初始化,使这个CTime变量的初始化值为最早的时间,达人能帮忙吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 CTime( int, int, etc.); Constructs a CTime object from local time components with each component constrained to the following ranges:Component Range nYear 1970–2038* nMonth 1–12 nDay 1–31 nHour no constraint nMin no constraint nSec no constraint 不给他赋值就是了吧,好像是1970-01-01。不过你的算法不需要这样,先取到一个文件时间,逐个比较就是了,与CTime的初始化没有关系。 CTime ( int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec, int nDST = -1) );这个就可以的啊.你把里面的参数设置成足够早的时间 CTime 时间范围太小了。只能表示1970–2038年的时间范围。用COleDateTime吧,它可表示100 – 9999年的时间范围。COleDateTime time(100, 0, 0, 12, 0, 0);呵呵~~ GETLOCALTIME()然后转换一下 CTime time = GetCurrentTime(); 楼上的不对,应是:CTime time = CTime::GetCurrentTime();//Initialize with current time CTime time = CTime::GetCurrentTime();//Initialize with current timeCTime time1( 2004, 9, 8, 13, 33, 0 ); // 2004年9月8日13点33分0秒CTimeSpan来保存当前时间与文件创建时间的差CTimeSpan ts = time - time1;至于怎么取最小的就好解决了吧 CTime time = CTime::GetCurrentTime();CString str = time.Format("%Y %d %A %B"); WSAAsyncselect模型? MFC提供TabControl能添加几个页面 网络编程生产者与消费者的相关问题,请指点迷津 刚完成了一个在基于MFC的项目中使用ActiveX, .NET控件的组件,感兴趣的高手帮忙测试下,谢谢 关于mfc中默认ID_FILE_OPEN的问题,帮帮我!!!!!!! PDF转化为HTML或WORD文档 com高手看过来! 不喜欢3721的几大理由 请问,VS.net(英文版)的能不能装在win2000 中文版上? 怎么修改应用程序的图标 超初级问题,呵呵 为什么我在对话框中放控件 在Caption里输入汉字后 控件上的汉字会变成横的 马上结帖
nYear 1970–2038*
nMonth 1–12
nDay 1–31
nHour no constraint
nMin no constraint
nSec no constraint
不过你的算法不需要这样,先取到一个文件时间,逐个比较就是了,与CTime的初始化没有关系。
你把里面的参数设置成足够早的时间
COleDateTime time(100, 0, 0, 12, 0, 0);
呵呵~~
然后转换一下
CTime time = CTime::GetCurrentTime();//Initialize with current time
CTime time1( 2004, 9, 8, 13, 33, 0 ); // 2004年9月8日13点33分0秒
CTimeSpan来保存当前时间与文件创建时间的差
CTimeSpan ts = time - time1;
至于怎么取最小的就好解决了吧
CString str = time.Format("%Y %d %A %B");