如题.
我需要得到一个计时开始到终止之间有多少秒,不使用CTime类的话,要如何做呢.

解决方案 »

  1.   

    对于两个SYSTEMTIME类型的时间,返回的毫秒数
    你想获得秒,再除以1000就好了
    _int64 GetTwoTime(SYSTEMTIME &myTime1, SYSTEMTIME &myTime2)
    {
    ULARGE_INTEGER fTime1;/*FILETIME*/
    ULARGE_INTEGER fTime2;/*FILETIME*/ SystemTimeToFileTime(&myTime1,(FILETIME*)&fTime1);
    SystemTimeToFileTime(&myTime2,(FILETIME*)&fTime2);    return ((_int64)(fTime2.QuadPart-fTime1.QuadPart)/10000);
    }
      

  2.   

    用GetTickCount相对来说比较精确
      

  3.   

    开始及结束时分别调用GetTickCount,计算时间差。
      

  4.   

    如果我要使用
    #include <time.h>
    里的那一些东西呢.不使用VC里的那一些Windows里的东西.
      

  5.   

    #include "stdafx.h"
    #include "string.h"
    #include <time.h>
    int main(int argc, char* argv[])
    {
    struct tm *newtime;
    char am_pm[] = "AM";
    time_t long_time;

    time( &long_time );                /* Get time as long integer. */
    newtime = localtime( &long_time ); /* Convert to local time. */
    getchar();
    struct tm *newtime1; time( &long_time );                /* Get time as long integer. */
    newtime1 = localtime( &long_time ); /* Convert to local time. */

    return 0;
    }这样就可以得到两个 tm的时间,不过他的减法的确用起来不爽.
      

  6.   

    GetSystemTime(1);//GetSystemTime(2);yourtime = 2 - 1;