System Restore Point
Is there a way to get an NSIS installer to create a Windows System Restore Point. Also how does the system restore descide which files it should 'protect'?
Vytautas
Archive: System Restore Point
System Restore Point
Is there a way to get an NSIS installer to create a Windows System Restore Point. Also how does the system restore descide which files it should 'protect'?
Vytautas
MSDN is your best friends when it comes to Windows API:
http://msdn.microsoft.com/library/en...estore_api.asp
After a look at MSDN pages related to this I think that the easiest thing would be to use the system plugin to do this.
One question since I am not very familiar with the MSDN: The RESTOREPOINTINFO structure has a couple of DWORD parameters, e.g. BEGIN_SYSTEM_INSTALL and APPLICATION_INSTALL etc. Where do I find the definitions of these constants so I can define them in NSIS.
Vytautas
You need to dig it from the header files. The MSDN page specifies which one it is. In this case, SRRestorePtAPI.h. The header files come with the Platform SDK, which is freely available for download from MSDN. To save you the trouble:
!define MIN_EVENT 100
!define BEGIN_SYSTEM_CHANGE 100
!define END_SYSTEM_CHANGE 101
!define BEGIN_NESTED_SYSTEM_CHANGE 102 # for Whistler only - use this to prevent nested restore pts
!define END_NESTED_SYSTEM_CHANGE 103 # for Whistler only - use this to prevent nested restore pts
!define MAX_EVENT 103
#
# Type of Restore Points
#
!define MIN_RPT 0
!define APPLICATION_INSTALL 0
!define APPLICATION_UNINSTALL 1
!define DESKTOP_SETTING 2 # Not implemented
!define ACCESSIBILITY_SETTING 3 # Not implemented
!define OE_SETTING 4 # Not implemented
!define APPLICATION_RUN 5 # Not implemented
!define RESTORE 6
!define CHECKPOINT 7
!define WINDOWS_SHUTDOWN 8 # Not implemented
!define WINDOWS_BOOT 9 # Not implemented
!define DEVICE_DRIVER_INSTALL 10
!define FIRSTRUN 11
!define MODIFY_SETTINGS 12
!define CANCELLED_OPERATION 13 # Only valid for END_SYSTEM_CHANGE
!define BACKUP_RECOVERY 14
Sorry about this but do you need to specify the dll file that contains the 'SRSetRestorePoint' function when you use the system::call and if so does anyone know which dll that would be?
Vytautas
It's alright I figgured out which dll has the right function. However when I call it it does not seem to create a restore point.
When called it returns the error code 127, not sure what that actually means. Is it possible that a restore point is only created if there was a system change?
Attached is a test script.
Vytautas :(
127 means the function could not be found. Use this program to convert error code to text. There are a lot others, but this one came first on Google. If you're using the latest CVS version it's probably because the System plug-in couldn't findSRSetRestorePoint so it looked for SRSetRestorePointA and kept the error behind. If you're not using the latest CVS version, you must append the A to the function name.
Now, for the reason it's not working... You can't pass the struct's items as function parameters. You must allocate memory for the struct and pass a pointer to it. See System examples for an example of allocating and using a struct (WNDCLASS for example).