当前位置: 代码迷 >> Windows Mobile >> Windows Mobile C++编写类库怎么获取系统当前时间?只要时分秒
  详细解决方案

Windows Mobile C++编写类库怎么获取系统当前时间?只要时分秒

热度:106   发布时间:2016-04-25 07:48:54.0
Windows Mobile C++编写类库如何获取系统当前时间?只要时分秒
最好能给个小例子,本人初学,讲解一下,谢谢各位大侠!!

------解决方案--------------------
C/C++ code
SYSTEMTIME sysTime;GetLocalTime(&sysTime);
------解决方案--------------------
1.使用CTime类

CString str;

//获取系统时间

CTime tm;

tm=CTime:: GetCurrentTime_r();

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

MessageBox(str,NULL,MB_OK);


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

SYSTEMTIME st;

CString strDate,strTime;

GetLocalTime_r(&st);

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

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

  相关解决方案