IOpcFactory::CreateStreamOnFile method (msopc.h)

Creates a stream over a file. This method is a simplified wrapper for a call to the CreateFile function. CreateFile parameters that are not exposed through this method use their default values. For more information, see CreateFile.

Syntax

HRESULT CreateStreamOnFile(
  [in]          LPCWSTR               filename,
  [in]          OPC_STREAM_IO_MODE    ioMode,
  [in]          LPSECURITY_ATTRIBUTES securityAttributes,
  [in]          DWORD                 dwFlagsAndAttributes,
  [out, retval] IStream               **stream
);

Parameters

[in] filename

The name of the file over which the stream is created.

[in] ioMode

The value that describes the read/write status of the stream to be created.

[in] securityAttributes

For information about the SECURITY_ATTRIBUTES structure in this parameter, see the CreateFile function.

[in] dwFlagsAndAttributes

The settings and attributes of the file. For most files, FILE_ATTRIBUTE_NORMAL can be used.

For more information about this parameter, see CreateFile.

[out, retval] stream

A pointer to the IStream interface of 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 ioMode parameter is not a valid OPC_STREAM_IO_MODE enumeration value.
E_POINTER
At least one of the filename and stream parameters is NULL.
CreateFile function error
An HRESULT error code from the CreateFile function.

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 using this method when loading or saving a package, see the Loading a Package or Saving a Package programming task.

Support on Previous Windows Versions

The behavior and performance of this method is the same on all supported Windows versions. 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, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps only]
Target Platform Windows
Header msopc.h

See also

CreateFile

ECMA-376 OpenXML

External Resources

Getting Started with the Packaging API

IOpcFactory

Loading a Package

OPC_STREAM_IO_MODE

Overviews

Packaging API Programming Guide

Packaging API Reference

Packaging API Samples

Packaging Errors

Parts Overview

Platform Update for Windows Vista

RFC 3986: URI Generic Syntax

Reference

Saving a Package