QQ登录

只需一步,快速开始

上位机MFC如何获取系统当前时间?

[ 复制链接 ]
  1. void CDemoDlg::OnTest()
  2. {
  3.         CTime time;

  4.         //获得当前时间
  5.         time = CTime::GetCurrentTime();

  6.         CString strText = _T("");
  7.         strText.Format(_T("%d-%d-%d\n%d:%d:%d"),
  8.                 time.GetYear(), time.GetMonth(), time.GetDay(),
  9.                 time.GetHour(), time.GetMinute(), time.GetSecond());
  10.         AfxMessageBox(strText);
  11. }
复制代码
上面的代码可以添加一个按钮元件来调用。
主要是通过CTime的成员函数来实现。

回复

使用道具 举报

点击查看
快速回复 返回列表 客服中心 搜索