/// time_t MySystemTimeToTimet(SYSTEMTIME st ) { FILETIME ft; SystemTimeToFileTime( &st, &ft ); LONGLONG nLL; ULARGE_INTEGER ui; ui.LowPart = ft.dwLowDateTime; ui.HighPart = ft.dwHighDateTime; nLL = (ft.dwHighDateTime << 32) + ft.dwLowDateTime; time_t pt = (long)((LONGLONG)(ui.QuadPart - 116444736000000000) / 10000000); return pt; } // SYSTEMTIME MyTimetToSystemTime(time_t t) { FILETIME ft; SYSTEMTIME pst; LONGLONG nLL = Int32x32To64(t, 10000000) + 116444736000000000; ft.dwLowDateTime = (DWORD)nLL; ft.dwHighDateTime = (DWORD)(nLL >> 32); FileTimeToSystemTime(&ft, &pst); return pst; } // void ChangeDay(SYSTEMTIME& sysTime,int day) { FILETIME ft={0}; SystemTimeToFileTime(&sysTime, &ft); ULONGLONG qwResult; // Copy the time into a quadword. qwResult = (((ULONGLONG) ft.dwHighDateTime) << 32) + ft.dwLowDateTime; // minus 2 hours. qwResult += day * 86400 * (ULONGLONG)10000000; // Copy the result back into the FILETIME structure. ft.dwLowDateTime = (DWORD) (qwResult & 0xFFFFFFFF ); ft.dwHighDateTime = (DWORD) (qwResult >> 32 ); FileTimeToSystemTime(&ft, &sysTime); } / SYSTEMTIME* CStringToSystemTime(CString str) { int nYear = 0; int nMonth = 0; int nDay = 0; int nHour = 0; int nSecond = 0; int nMinute = 0; SYSTEMTIME time; _stscanf(str, _T("%d-%d-%d"), &nYear, &nMonth, &nDay); time.wYear = nYear; time.wMonth = nMonth; time.wDay = nDay; time.wHour = nHour; time.wSecond = nSecond; time.wMinute = nMinute; return &time; } void SetTimeEdit(CDateTimeCtrl *ctrl,CString str)设置控件时间 { ctrl->UpdateData(TRUE); LPSYSTEMTIME time=CStringToSystemTime(str); CTime ctime(2011,11,11,time->wHour,time->wMinute,time->wSecond); ctrl->SetTime(&ctime); ctrl->SetFormat(_T("HH:mm:ss")); } void CStringToSystemTime(CString str,SYSTEMTIME &time,BOOL isYear) {//str 08:00:00 COleDateTime m_CurDate; m_CurDate.ParseDateTime(str,0); m_CurDate.GetAsSystemTime(time); }