IVssBackupComponents::DeleteSnapshots method (vsbackup.h)

The DeleteSnapshots method deletes one or more shadow copies or a shadow copy set.

Syntax

HRESULT DeleteSnapshots(
  [in]  VSS_ID          SourceObjectId,
  [in]  VSS_OBJECT_TYPE eSourceObjectType,
  [in]  BOOL            bForceDelete,
  [out] LONG            *plDeletedSnapshots,
  [out] VSS_ID          *pNondeletedSnapshotID
);

Parameters

[in] SourceObjectId

Identifier of the shadow copy or a shadow copy set to be deleted.

[in] eSourceObjectType

Type of the object on which all shadow copies will be deleted. The value of this parameter is VSS_OBJECT_SNAPSHOT or VSS_OBJECT_SNAPSHOT_SET.

[in] bForceDelete

If the value of this parameter is TRUE, the provider will do everything possible to delete the shadow copy or shadow copies in a shadow copy set. If it is FALSE, no additional effort will be made.

[out] plDeletedSnapshots

Number of deleted shadow copies.

[out] pNondeletedSnapshotID

If an error occurs, the value of this parameter is the identifier of the first shadow copy that could not be deleted. Otherwise, it is GUID_NULL.

Return value

The following are the valid return codes for this method.

Value Meaning
S_OK
The shadow copies were successfully deleted.
E_ACCESSDENIED
The caller does not have sufficient backup privileges or is not an administrator.
E_INVALIDARG
One of the parameter values is not valid.
E_OUTOFMEMORY
The caller is out of memory or other system resources.
VSS_E_UNEXPECTED
Unexpected error. The error code is logged in the error log file. For more information, see Event and Error Handling Under VSS.

Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP:  This value is not supported until Windows Server 2008 R2 and Windows 7. E_UNEXPECTED is used instead.

VSS_E_OBJECT_NOT_FOUND
The specified shadow copy does not exist.
VSS_E_PROVIDER_VETO
Expected provider error. The provider logged the error in the event log. For more information, see Event and Error Handling Under VSS.
VSS_E_UNEXPECTED_PROVIDER_ERROR
Unexpected provider error. The error code is logged in the error log. For more information, see Event and Error Handling Under VSS.

Remarks

Multiple shadow copies in a shadow copy set are deleted sequentially. If an error occurs during one of these individual deletions, DeleteSnapshots will return immediately; no attempt will be made to delete any remaining shadow copies. The VSS_ID of the undeleted shadow copy is returned in pNondeletedSnapshotID.

The requester is responsible for serializing the delete shadow copy operation.

During a backup, shadow copies are automatically released as soon as the IVssBackupComponents instance is released. In this case, it is not necessary to explicitly delete shadow copies.

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header vsbackup.h (include VsBackup.h, Vss.h, VsWriter.h)
Library VssApi.lib

See also

IVssBackupComponents

IVssBackupComponents::StartSnapshotSet

VSS_ID