//初始化 zhu,chong,guan=0;
void CMyDlg::OnTimer(UINT nIDEvent)
{
UpdateData(true);
if(nIDEvent==2)
{
str1=m_year+"-"+m_month+"-"+m_day+" "+m_hour+":"+m_mimute+":"+m_second;
CTime CTime1=CTime::GetCurrentTime();
m_CurrentTime=CTime1.Format("%Y-%m-%d %H:%M:%S");
if(strcmp(str1,m_CurrentTime)==0)
{
if(zhu==1)
{
// AfxMessageBox("要注销了!");
system("Shutdown -l -t 0");
}
if(chong==1)
{
// AfxMessageBox("要重启了!");
system("Shutdown -r -t 0");
}
if(guan==1)
{
// AfxMessageBox("要关机了!");
system("Shutdown -s -t 0");
}
}
}
UpdateData(false);
CDialog::OnTimer(nIDEvent);
}
int CMyDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
SetTimer(2,1000,NULL);
return 0;
}
void CMyDlg::OnDestroy()
{
CDialog::OnDestroy();
KillTimer(2);
}
void CMyDlg::OnGunji()
{
UpdateData(true);
guan=1;
UpdateData(false);
}
void CMyDlg::OnZhuxiao()
{
UpdateData(true);
zhu=1;
UpdateData(false);
}
void CMyDlg::OnChongqi()
{
UpdateData(true);
chong=1;
UpdateData(false);
}