我编一个程序需要搜索创建时间最早的文件,我用一个CTime变量time来表示所搜索到的文件的最早创建时间,这个值应该初始化成比任何文件创建的时间更早的值。
我现在不知道如何初始化,使这个CTime变量的初始化值为最早的时间,达人能帮忙吗?

解决方案 »

  1.   

    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 
      

  2.   

    不给他赋值就是了吧,好像是1970-01-01。
    不过你的算法不需要这样,先取到一个文件时间,逐个比较就是了,与CTime的初始化没有关系。
      

  3.   

    CTime ( int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec, int nDST = -1) );这个就可以的啊.
    你把里面的参数设置成足够早的时间
      

  4.   

    CTime 时间范围太小了。只能表示1970–2038年的时间范围。用COleDateTime吧,它可表示100 – 9999年的时间范围。
    COleDateTime time(100, 0, 0, 12, 0, 0);
    呵呵~~
      

  5.   

    GETLOCALTIME()
    然后转换一下
      

  6.   

    CTime time = GetCurrentTime();
      

  7.   

    楼上的不对,应是:
    CTime time = CTime::GetCurrentTime();//Initialize with current time
      

  8.   

    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;
    至于怎么取最小的就好解决了吧
      

  9.   

    CTime time = CTime::GetCurrentTime();
    CString str = time.Format("%Y  %d %A  %B");