IOpcFactory::WritePackageToStream method (msopc.h)

Serializes a package that is represented by a package object.

Syntax

HRESULT WritePackageToStream(
  [in] IOpcPackage     *package,
  [in] OPC_WRITE_FLAGS flags,
  [in] IStream         *stream
);

Parameters

[in] package

A pointer to the IOpcPackage interface of the package object that contains data to be serialized.

[in] flags

The value that describes the encoding method used in serialization.

[in] stream

A pointer to the IStream interface of the stream where the package object data will be written.

Return value

The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.

Return code Description
S_OK
The method succeeded.
E_INVALIDARG
The value passed in the flags parameter is not a valid OPC_WRITE_FLAGS enumeration value.
E_NOTIMPL
This method is not implemented for this version of Windows.
E_POINTER
At least one of the stream and package parameters is NULL.
IStream interface error
An HRESULT error code from the IStream interface.
Package Consumption error
An HRESULT error code from the Package Consumption Error Group.
Part URI error
An HRESULT error code from the Part URI Error Group.

Remarks

Do not use a stream to serialize package data when the same stream is being used to deserialize a package, because the attempt may result in undefined behavior.

For information about how to use this method to save a package that is represented as a package object, see the Saving a Package programming task.

Support on Previous Versions of Windows

This method is not supported on versions of Windows prior to Windows 7. For more information, see Getting Started with the Packaging API, and Platform Update for Windows Vista.

Thread Safety

Packaging objects are not thread-safe.

For more information, see the Getting Started with the Packaging API.

Requirements

Requirement Value
Minimum supported client Windows 7 [desktop apps only]
Minimum supported server Windows Server 2008 R2 [desktop apps only]
Target Platform Windows
Header msopc.h

See also

Getting Started with the Packaging API

IOpcFactory

OPC_WRITE_FLAGS

Overviews

Packaging API Programming Guide

Packaging API Reference

Packaging API Samples

Packaging Errors

Platform Update for Windows Vista

Reference

Saving a Package