CVssWriter::OnPrepareSnapshot method (vswriter.h)

The OnPrepareSnapshot method is called by a writer to handle a PrepareForSnapshot event. It is used to perform operations needed to prepare a writer to participate in the shadow copy or to veto a shadow copy.

OnPrepareSnapshot is a pure virtual method. It is not implemented by the CVssWriter base class, and must be implemented by derived classes.

Syntax

bool OnPrepareSnapshot();

Return value

The implementation of this method must return true except in the case of a fatal error. If a fatal error occurs, the method must call the CVssWriter::SetWriterFailure method to provide a description of the failure before returning false. If a nonfatal error occurs, the method should still call SetWriterFailure but return true. If the error is caused by a transient problem, the method should specify VSS_E_WRITERERROR_RETRYABLE in the call to SetWriterFailure.

In all cases when a failure occurs, the method should write an event to the event log to report the exact reason for the failure.

Remarks

The OnPrepareSnapshot method performs operations that are required prior to any shadow copy freeze.

The time-out window for handling a PrepareForSnapshot event is typically longer than that for handling a Freeze event. Therefore, developers can use OnPrepareSnapshot to handle more time-consuming operations. A typical use might be for the writer to explicitly checkpoint its data.

Writers should never throw an exception from this method or any other CVssWriter(Ex)::OnXxx callback method.

If this method calls the CVssWriterEx2::GetSessionId, CVssWriter::SetWriterFailure, or CVssWriterEx2::SetWriterFailureEx method, it must do so in the same thread that called this method. For more information, see Writer Event Handling.

Requirements

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

See also

CVssWriter

CVssWriter::OnAbort

CVssWriter::OnFreeze

CVssWriter::OnThaw

CVssWriter::SetWriterFailure