CTime类只能取到秒的时间,我想取得毫秒级的时间,怎么办呢

解决方案 »

  1.   

    在一些计算机硬件系统中,包含有高精度运行计数器(high-resolution performance counter),利用它可以获得高精度定时间隔,其精度与CPU的时钟频率有关。采用这种方法的步骤如下: 
     
    1、首先调用QueryPerformanceFrequency函数取得高精度运行计数器的频率f。单位是每秒多少次(n/s),此数一般很大。 
    2、在需要定时的代码的两端分别调用QueryPerformanceCounter以取得高精度运行计数器的数值n1,n2。两次数值的差值通过f换算成时间间隔,t=(n2-n1)/f。 
    转摘,希望对你有帮助:
    http://www.ccw.com.cn/htm/app/aprog/01_1_17_4.asp
      

  2.   

    用SDK下的GetLocalTime()应该也可以。
      

  3.   

    GetSystemTime()就可以取到啊,何必那么复杂
      

  4.   

    _asm
    {
       _emit 0x0f
       _emit 0x31
    }
      

  5.   

    /* FTIME.C: This program uses _ftime to obtain the current
     * time and then stores this time in timebuffer.
     */#include <stdio.h>
    #include <sys/timeb.h>
    #include <time.h>void main( void )
    {
       struct _timeb timebuffer;
       char *timeline;   _ftime( &timebuffer );
       timeline = ctime( & ( timebuffer.time ) );   printf( "The time is %.19s.%hu %s", timeline, timebuffer.millitm, &timeline[20] );
    }