IAppxFactory3::CreatePackageReader2 method (appxpackaging.h)

Important

Some information relates to a prerelease product which may be substantially modified before it's commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Creates a read-only package reader from the contents provided by an IStream, with an optional parameter for specifying the expected digest for the package. This method does not validate the digital signature.

Syntax

HRESULT CreatePackageReader2(
  [in]          IStream            *inputStream,
  [in,optional] LPCWSTR            expectedDigest,
  [out]         IAppxPackageReader **packageReader
);

Parameters

[in] inputStream

The input stream that delivers the package for reading. The stream must support ISequentialStream::Read, IStream::Seek, and IStream::Stat. If these methods fail, their error codes may be passed to and returned by this method.

[in,optional] expectedDigest

An LPCWSTR containing the expected digest, a hashed representation of the package file.

[out] packageReader

The created package reader.

Return value

If the method succeeds, it returns S_OK. Otherwise, it returns an error code that includes, but is not limited to, those in the following table.

Return code Description
APPX_E_INTERLEAVING_NOT_ALLOWED The ZIP file delivered by inputStream is an interleaved OPC package.
APPX_E_RELATIONSHIPS_NOT_ALLOWED The OPC package delivered by inputStream contains OPC package/part relationships.
APPX_E_MISSING_REQUIRED_FILE The OPC package delivered by inputStream does not have a manifest, or a block map, or a signature file when a CI catalog is present.
APPX_E_INVALID_MANIFEST The package manifest is not valid.
APPX_E_INVALID_BLOCKMAP The package block map is not valid, the list of files in the ZIP central directory does not match the list of files in the block map, or the size of files listed in the ZIP central directory does not match the file and block sizes listed in the block map.
APPX_E_DIGEST_MISMATCH The digest for the object doesn't match the digest provided in expectedDigest.

Remarks

The CreatePackageReader2 method immediately retrieves footprint elements of the app package through the stream and validates their content. This method succeeds only if the OPC package and all footprint elements (including ZIP central directory, manifest, [Content_Types].xml, and block map) are valid.

Get the digest string for the expecteDigest parameter by calling IAppxDigestProvider::GetDigest.

Examples

For an example, see Quickstart: Extract app package contents and Quickstart: Read app package manifest info.

Requirements

Requirement Value
Header appxpackaging.h