当前位置: 代码迷 >> WinCE >> 获取系统时间有关问题
  详细解决方案

获取系统时间有关问题

热度:84   发布时间:2016-04-28 12:27:26.0
获取系统时间问题
CString strDate,strTime;
SYSTEMTIME st;
GetLocalTime(&st);
strDate.Format("%4d-%2d-%2d",st.wYear,st.wMonth,st.wDay);
strTime.Format("%2d:%2d:%2d",st.wHour,st.wMinute,st.wSecond);


这是按照百度上面的方法,但是老是报错,


求指导啊

------解决方案--------------------
字符串在 CE 下需要使用 Unicode

CE 下所有 API 都是 Unicode 版本,例如如下写法(多一个 L):
strDate.Format(L"%4d-%2d-%2d",st.wYear,st.wMonth,st.wDay);
------解决方案--------------------
引用:
字符串在 CE 下需要使用 Unicode

CE 下所有 API 都是 Unicode 版本,例如如下写法(多一个 L):
strDate.Format(L"%4d-%2d-%2d",st.wYear,st.wMonth,st.wDay);



楼上似乎是正解!
------解决方案--------------------
对,wince里需要添加一个宏,表示你这是Unicode版本,像_T(“”)或者TEXT(""),楼上说的也该是对的,虽然没用过这个宏。下面是实例:
strDate.Format(_T("%4d-%2d-%2d"),st.wYear,st.wMonth,st.wDay);
  相关解决方案