Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Comments
The_Inventor 30-Aug-13 23:13pm    
You need to 'register' your restore point, with the system restore service, that initializes the dialog with the list. Choosing a Different Restore Point, performs a wider, or deeper search. Is your restore point being saved to the directory where the other RP are stored?
HalliHaida 2-Sep-13 0:46am    
Hi,

Sorry, I couldn't get the way to programatically register the created restore point. Also, I am not able to see System Volume Information directory in C: drive on my machine where it is told that restore points will be saved.I tried through command prompt with admin privilege also, still it says "Access is denied".

However, since it appears in the list when opted for "Choose a different restore", I believe the created restore point is being saved.

Any help for the above mentioned two issues is really appreciated.
The_Inventor 2-Sep-13 23:20pm    
What you might have been able to do on a Windows - pre-NT OS, when FAT32 was in vogue, your code would have worked, and in the process, may have killed your OS, CPU, and thus an unusable computer, with no way of knowing what exactly happened. AS was many the case for experimenters. Since then, MS has made the OS, fairly USER PROOF, so that writing and running code on the same machine is made possible without making the system totally unusable. There many processes that run that have names that I may not like, so I kill them, to see if it fixes or FUBAR's the issue that I think that I am having with the CPU in that it's tied up, or hogging memory, or whatever it is that's running, that I didn't tell it to run, or had exited but left a process running. As a CAD person, I can't count the number times that the use of ACAD had overloaded the system, and crashed the entire computer, OS and all. Now its all virtual. Virtual machine, virtual OS, virtual memory, and so on. There is no direct access to the file structure any more, at least for the typical user. The current HDD access with its hidden protected disk memory, that is allocated when it is initially formatted, is much more secure, stable, and maintainable.

It is because an OUTSIDE generated SRP is very dangerous to use, as it could be made malware style, and then you are really screwed, if is something that 'someone nice' helped you with when you thought you were having trouble before, has made you machine useable to others, without your knowledge. Progress marches on.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900