//backs up the specified keyName into regfile, in currentFolderPath
backupReg(CString keyName,CString regFile,CString currentFolderPath)
{
CString commandLine;
commandLine ="/E \""+ regFile +"\" " + keyName;
SHELLEXECUTEINFO sei;
ZeroMemory( &sei, sizeof(sei) );
sei.cbSize=sizeof(sei);
sei.fMask=SEE_MASK_NOCLOSEPROCESS;
sei.lpVerb=_T("open");
sei.lpFile=_T("regedit");
sei.nShow=SW_SHOW;
sei.lpParameters=_T(commandLine);
sei.lpDirectory=currentFolderPath;
if(!ShellExecuteEx(&sei))
{
MessageBox(NULL,"Unable to backup " + keyName + " settings","Error",MB_OK|MB_ICONERROR);
return -1;
}
else
{
WaitForSingleObject( sei.hProcess, INFINITE );
}
CloseHandle(sei.hProcess);
return 0;
}