MFC中定時關機、重啓、註銷的實現

今天閒得無聊,覺得也應該練練手了,就沒事寫了個定時關機,重啓,註銷的小程序,先簡單看一下程序的效果吧:
MFC中定時關機、重啓、註銷的實現MFC中定時關機、重啓、註銷的實現
註銷和重啓操作就不演示了,實在是有點麻煩,下面看一下MFC下的簡單實現:
其實這些操作都是調用系統命令來實現的,簡單的不得了:
void CMyDlg::OnButtonClose() 
{
// TODO: Add your control notification handler code here
UpdateData(true);
CString B;
CString C="shutdown -s -t ";
CString D=" -c ";
B=C+m_nTime+D+m_nText;
system(B);
UpdateData(false);
}

void CMyDlg::OnButtonZhuxiao() 
{
// TODO: Add your control notification handler code here
system("shutdown -l");
MessageBox("註銷");
}

void CMyDlg::OnButtonReboot() 
{
// TODO: Add your control notification handler code here
system("shutdown -r");
MessageBox("重啓");
}

void CMyDlg::OnButtonCancel() 
{
// TODO: Add your control notification handler code here
system("shutdown -a");
MessageBox("取消操作");
}

void CMyDlg::OnButtonClosedlg() 
{
// TODO: Add your control notification handler code here
MessageBox("關閉窗口");
CDialog::OnCancel();
}

void CMyDlg::OnButtonAbout() 
{
// TODO: Add your control notification handler code here
CAboutDlg dlg;
dlg.DoModal();
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章