IOpcFactory::ReadPackageFromStream method (msopc.h)

Deserializes package data from a stream and creates a package object to represent the package being read. While a Packaging API object obtained from the package object, or the package object itself, is still in use, the stream may be used to access package data.

Syntax

HRESULT ReadPackageFromStream(
  [in]          IStream        *stream,
  [in]          OPC_READ_FLAGS flags,
  [out, retval] IOpcPackage    **package
);

Parameters

[in] stream

A pointer to the IStream interface of the stream.

The stream must be readable, seekable, have size, and must contain package data. Additionally, if the stream is not cloneable, it will be buffered and read sequentially, incurring overhead.

[in] flags

The value that specifies the read settings for caching package components and validating them against OPC conformance requirements.

[out, retval] package

A pointer to the IOpcPackage interface of the package object that represents the package being read through the stream.

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_READ_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.

The Packaging APIs can interact with packages that map a ZIP archive as specified in the OPC, and that are based on either Zip32 (ZIP 2.0) or Zip64 (ZIP 4.5) encoding.

For information about how to use this method to load a package, see the Loading 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

Loading a Package

OPC_READ_FLAGS

Overviews

Packaging API Programming Guide

Packaging API Reference

Packaging API Samples

Packaging Errors

Platform Update for Windows Vista

Reference