예제 #1
0
void Cleanup(bool bAbnormalAbort, bool bSnapshotCreated, const CString& mountedDevice, CComPtr<IVssBackupComponents> pBackupComponents, GUID snapshotSetId)
{
    if (pBackupComponents == NULL)
    {
        return; 
    }

    if (bAbnormalAbort)
    {
        OutputWriter::WriteLine(TEXT("Aborting backup."), VERBOSITY_THRESHOLD_NORMAL);
        pBackupComponents->AbortBackup(); 
    }
    if (!mountedDevice.IsEmpty())
    {
        if (bAbnormalAbort)
        {
            CString message;
            message.AppendFormat(TEXT("Dismounting device: %s"), mountedDevice);
            OutputWriter::WriteLine(message, VERBOSITY_THRESHOLD_NORMAL);
        }
        BOOL bWorked = DefineDosDevice(DDD_REMOVE_DEFINITION, mountedDevice, NULL); 
        if (!bWorked)
        {
            DWORD error = ::GetLastError(); 
            CString errorMessage; 
            Utilities::FormatErrorMessage(error, errorMessage); 
            CString message; 
            message.AppendFormat(TEXT("There was an error calling DefineDosDevice during Cleanup. Error: %s"), errorMessage); 
            OutputWriter::WriteLine(message);
        }
    }
    if (bSnapshotCreated)
    {
        if (bAbnormalAbort)
        {
            OutputWriter::WriteLine(TEXT("Deleting snapshot."), VERBOSITY_THRESHOLD_NORMAL);
        }
        LONG cDeletedSnapshots; 
        GUID nonDeletedSnapshotId; 
        pBackupComponents->DeleteSnapshots(snapshotSetId, VSS_OBJECT_SNAPSHOT_SET, TRUE, 
            &cDeletedSnapshots, &nonDeletedSnapshotId); 
    }
}
예제 #2
0
void Cleanup(bool bAbnormalAbort, bool bSnapshotCreated, CComPtr<IVssBackupComponents> pBackupComponents, GUID snapshotSetId)
{
	if (pBackupComponents == NULL)
	{
		return;
	}

	if (bAbnormalAbort)
	{
		pBackupComponents->AbortBackup();
	}
	if (bSnapshotCreated)
	{
		LONG cDeletedSnapshots;
		GUID nonDeletedSnapshotId;
		pBackupComponents->DeleteSnapshots(snapshotSetId, VSS_OBJECT_SNAPSHOT_SET, TRUE,
			&cDeletedSnapshots, &nonDeletedSnapshotId);
	}
}