CFile::modeWrite,NULL);
CString m_strCommand=toShortPath(m_strWinDir)+"\\command\\scanreg.exe/backup\n";
f.WriteString(m_strCommand);
f.Close();
WinExec(getMyDir()+"myTemp.bat",SW_HIDE);
CString m_toRbName;
m_toRbName.Format("rb0%d.cab", m_savedNum); //格式化存储文件名.
CTime m_beginTime=CTime::GetCurrentTime();
CTimeSpan m_timeSpan=CTime::GetCurrentTime()-m_beginTime;
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
int delayTime=150/sysInfo.wProcessorLevel; //根据计算机的速度算出大致的完成时间.
while(!CopyFile(m_strWinDir+"\\sysbckup\\rb000.cab",getMyDir()+m_toRbName,0))
{
MSG msg;
if(::PeekMessage(&msg,m_hWnd,0,0,PM_REMOVE))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
if(!(m_progress.GetPos()>=100))
m_progress.SetPos(100*m_timeSpan.GetSeconds()/delayTime);
m_timeSpan=CTime::GetCurrentTime()-m_beginTime;
}
m_progress.SetPos(100);
AfxMessageBox("已经成功的备份了系统文件");
DeleteFile(getMyDir()+"myTemp.bat");
}
6.为"开始恢复"按钮或菜单项生成一个响应函数:
void CRescueSysDlg::OnBeginRestore()
{
CRestoreDlg m_restoreDlg;
// CRestoreDlg是一个对话框类,用来将用户输入的恢复名称保存在m_restoreDlg.m_strSeled中.
if(IDCANCEL==m_restoreDlg.DoModal())
return;
CStdioFile f; //建立Autoexec.bat和rescueS.bat,将恢复系统的命令写入.
f.Open(getMyDir()+"Autoexec.bat", CFile::modeCreate(北联网教程,专业提供视频软件下载)
……