当前所在位置:珠峰网资料 >> 计算机 >> 计算机等级考试 >> 正文
VC获取系统时间方法
发布时间:2010/5/17 11:18:45 来源:城市学习网 编辑:ziteng
  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)
广告合作:400-664-0084 全国热线:400-664-0084
Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号
珠峰网 版权所有 All Rights Reserved