设为首页 加入收藏

TOP

VC获取系统时间方法
2014-11-10 23:30:07 】 浏览:810
Tags:获取 系统 时间 方法

  1.使用CTime类


  CTime tm=CTime::GetCurrentTime();


  CString str=tm.Format("现在时间是:%Y年%m月%d日 %X");


  MessageBox(str,NULL,MB_OK);


  2: 得到系统时间日期(使用GetLocalTime)


  SYSTEMTIME st;


  CString strDate,strTime;


  GetLocalTime(&st);


  strDate.Format("%4d-%2d-%2d",st.wYear,st.wMonth,st.wDay);


  strTime.Format("%2d:%2d:%2d",st.wHour,st.wMinute,st.wSecond);


  3.使用GetTickCount//获取程序运行时间


  long t1=GetTickCount();//程序段开始前取得系统运行时间(ms)


  。。。//程序段


  long t2=GetTickCount();//程序段结束后取得系统运行时间(ms)


  long t = t2-t1; //前后之差即 程序运行时间 (ms)


  编辑特别推荐:


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇输出电脑的所有Mac地址 下一篇VisualC++链接器选项

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目