欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

MFC获取时间差

程序员文章站 2024-01-29 10:25:28
...

CTime t1,t2;
CString startTimeStr,endTimeStr;
void CCycleTimeDlg::OnBnClickedBtnStart()
{
t1 = CTime::GetCurrentTime();
startTimeStr.Format("%02d:%02d:%02d",t1.GetHour(),t1.GetMinute(), t1.GetSecond());
}

void CCycleTimeDlg::OnBnClickedBtnEnd()
{
t2 = CTime::GetCurrentTime();
endTimeStr.Format("%02d:%02d:%02d",t2.GetHour(),t2.GetMinute(), t2.GetSecond());

CTimeSpan a = t2-t1;
int delay = a.GetMinutes()*60 + a.GetSeconds();

CString  CycleTime;
CycleTime.Format("%d",delay);

MessageBox(_T(CycleTime));

}

DWORD endTime;
CTime times=CTime::GetCurrentTime();
int curth,curtm,edh,edm;
curth = times.GetHour();
curtm = times.GetMinute();
edh = GetDlgItemInt(IDC_ED_HOUR);
edm = GetDlgItemInt(IDC_ED_MINT);
if (curth >= edh)
{
	if (curtm >= edm)
	{
		MySystemShutdown();
	}
}
相关标签: mfc时间差