Hi All,
I am working on a POC where in I need to develop an application on Win7 and Win8, pure C++ win32 application, that modifies (like installs or un-installs) the system. Before that the application has to create a system restore point. I cannot use .net or C++/CLI.
I googled and found the below link
http://msdn.microsoft.com/en-us/library/windows/desktop/aa378987(v=vs.85).aspx
With this (SRSetRestorePoint API) I am able to create the system restore point (application gets the required admin privilege). But I am facing the following issues
1) If system restore or protection is disabled or turned off, then the API fails and will not create restore point.
Is there any such APIs (no .net method, only C++) using which I can enable system protection if turned off or disabled?
2) Though the restore point is getting created, it is not appearing in the "Recommended restore:" dialog in Computer->Properties->System Protection-> System Restore. This is where a newly and recently created restore point appears. But with this API it is not.
However, if we select, "Choose a different restore point" option, then the created restore point appears in that list.
Is there a way or what needs to be done to make the created restore point (created using SRSetRestorePoint API) appear in "Recommended restore:"?
Code snippet:
RESTOREPOINTINFO RstPt;
STATEMGRSTATUS MgrStat;
DWORD dwErr = ERROR_SUCCESS;
RstPt.dwRestorePtType = APPLICATION_UNINSTALL;
RstPt.dwEventType = BEGIN_SYSTEM_CHANGE;
_tcscpy(RstPt.szDescription, _T("Demo Restore Point"));
if (!SRSetRestorePoint(&RstPt, &MgrStat))
{
dwErr = MgrStat.nStatus;
if(dwErr == ERROR_SERVICE_DISABLED)
{
//What to do in this case?
}
return FALSE;
}
RstPt.dwEventType = END_SYSTEM_CHANGE;
RstPt.llSequenceNumber = MgrStat.llSequenceNumber;
if (!SRSetRestorePoint(&RstPt, &MgrStat))
{
return FALSE;
}
Any help or pointers will be appreciated.
Thanks in advance.