/// <returns>The sequence number</returns> public static Int64 CreateRestorePoint(String description, SystemRestoreType type) { if (!IsSystemRestoreAvailable()) { throw new NotSupportedException("System Restore is not supported"); } if (description == null) { throw new ArgumentNullException("description"); } if (description.Length > 256) { throw new ArgumentException("description cannot exceed 256 characters"); } _isCreating = true; RestorePointInfo point = new RestorePointInfo(); StateManagerStatus status = new StateManagerStatus(); point.dwEventType = (Int32)SystemRestoreEventType.BeginSystemChange; point.dwRestorePtType = (Int32)type; point.llSequenceNumber = 0; point.szDescription = description; NativeMethods.SetSystemRestorePoint(ref point, out status); if (status.nStatus != 0) { // throw? } return(status.llSequenceNumber); }
/// <summary> /// Creates or modifies the system restore point. /// </summary> /// <param name="info">Information about the restore point to create or modify.</param> /// <param name="status">Status information of the restore point created or modified.</param> /// <returns>True if the operation was successful; otherwise, false.</returns> /// <remarks> /// The error code is reset to 0 (success) after each call. /// </remarks> /// <seealso cref="SetNextErrorCode"/> public bool SetRestorePoint(RestorePointInfo info, out StateManagerStatus status) { status.SequenceNumber = this.SequenceNumber; status.ErrorCode = this.nextErrorCode; // Reset next error code. this.nextErrorCode = 0; return(0 == status.ErrorCode); }
/// <summary> /// Creates or modifies the system restore point. /// </summary> /// <param name="info">Information about the restore point to create or modify.</param> /// <param name="status">Status information of the restore point created or modified.</param> /// <returns>True if the operation was successful; otherwise, false.</returns> /// <remarks> /// The error code is reset to 0 (success) after each call. /// </remarks> /// <seealso cref="SetNextErrorCode"/> public bool SetRestorePoint(RestorePointInfo info, out StateManagerStatus status) { status.SequenceNumber = this.SequenceNumber; status.ErrorCode = this.nextErrorCode; // Reset next error code. this.nextErrorCode = 0; return 0 == status.ErrorCode; }
public static void CancelRestorePoint(Int64 sequenceNumber) { if (!IsSystemRestoreAvailable()) { throw new NotSupportedException("System Restore is not supported"); } RestorePointInfo point = new RestorePointInfo(); StateManagerStatus status = new StateManagerStatus(); point.dwEventType = (Int32)SystemRestoreEventType.EndSystemChange; point.dwRestorePtType = (Int32)SystemRestoreType.ApplicationCancelled; point.llSequenceNumber = sequenceNumber; NativeMethods.SetSystemRestorePoint(ref point, out status); if (status.nStatus != 0) { // throw? } }