如题:
如果计算两个SYSTEMTIME之间的差?不能使用CTime类,要在SDK下运行。

解决方案 »

  1.   

    It is not recommended that you add and subtract values from the SYSTEMTIME structure to obtain relative times. Instead, you should Convert the SYSTEMTIME structure to a FILETIME structure. 
    Copy the resulting FILETIME structure to a ULARGE_INTEGER structure. 按照MSDN的说法,你可以把 SYSTEMTIME 变量转换为 FILETIME 类型,然后把 FILETIME 转换为 ULARGE_INTEGER 类型,我们知道 ULARGE_INTEGER 是无符号大整数,可以直接用来进行数学运算,下面就简单了。
      

  2.   

    如果2个systemtime都是在程序中生成的变量,那么你可以用GetTickCount()来代替GetLocalTime(),GetTickCount返回的是从系统启动开始的毫秒数
      

  3.   

    调用GetSystemTime()、atoi()函数,
    然后计算出时间差。
      

  4.   

    用time_t有点问题,如下,主要是mktime()为什么总是返回-1?
    struct tm  tmCreate;
    memset((void*)&tmCreate,0,sizeof(tm));
                 tmCreate.tm_year=screateTime.wYear;//2004
    tmCreate.tm_mon=screateTime.wMonth;//11
    tmCreate.tm_mday=screateTime.wDay;//8
    tmCreate.tm_hour=screateTime.wHour;//12
    tmCreate.tm_min=screateTime.wMinute;//18 time_t ttCreate;
    ttCreate=mktime(&tmCreate);但是上面的mktime()返回-1,这是为什么呀?
      

  5.   

    SystemTimeToFileTime
    然后计算FILETIME之差,FILETIME的精度是100ns,FILETIME实际上也可以看着一个__int64.