获取系统当前时间

来源:互联网 发布:pascal语言编程设计 编辑:程序博客网 时间:2024/04/29 10:47
DWORD dwStart; //开始时间DWORD dwEnd; //现在时间dwStart = GetTickCount();while( 1 ){Sleep(2);dwEnd = GetTickCount(); //The number of milliseconds that have elapsed since the system was started indicates successif( abs( dwEnd - dwStart ) > 10000 ) //10 seconds{printf( "Network thread timeout!\n" );break;}//......}/*********************************************************************/time_t stime = time( NULL ); //开始时间time_t ntime; //现在时间BOOL bTimeover = FALSE;while( !bTimeover ){Sleep(2);ntime = time( NULL ); //现在时间if((ntime - stime) > 10 ) //10s 花费的时间{bTimeover = TRUE;}//......}/*********************************************************************///获取时间time_t t;char buf[512] = { 0 };t = time( 0 );strftime( buf, sizeof( buf ), "%Y%m%d %H%M%S", localtime(&t) );


 

原创粉丝点击