IStorage::CreateStream method

The CreateStream method creates and opens a stream object with the specified name contained in this storage object. All elements within a storage objects, both streams and other storage objects, are kept in the same name space.

Syntax


HRESULT CreateStream(
  [in]   const WCHAR *pwcsName,
  [in]   DWORD grfMode,
  [in]   DWORD reserved1,
  [in]   DWORD reserved2,
  [out]  IStream **ppstm
);

Parameters

pwcsName [in]

A pointer to a wide character null-terminated Unicode string that contains the name of the newly created stream. The name can be used later to open or reopen the stream. The name must not exceed 31 characters in length, not including the string terminator. The 000 through 01f characters, serving as the first character of the stream/storage name, are reserved for use by OLE. This is a compound file restriction, not a structured storage restriction.

grfMode [in]

Specifies the access mode to use when opening the newly created stream. For more information and descriptions of the possible values, see STGM Constants.

reserved1 [in]

Reserved for future use; must be zero.

reserved2 [in]

Reserved for future use; must be zero.

ppstm [out]

On return, pointer to the location of the new IStream interface pointer. This is only valid if the operation is successful. When an error occurs, this parameter is set to NULL.

Return value

This method can return one of these values.

S_OK

The new stream was successfully created.

E_PENDING

Asynchronous Storage only: Part or all of the necessary data is currently unavailable. For more information, see IFillLockBytes and Asynchronous Storage.

STG_E_ACCESSDENIED

Not enough permissions to create stream.

STG_E_FILEALREADYEXISTS

The name specified for the stream already exists in the storage object and the grfMode parameter includes the value STGM_FAILIFTHERE.

STG_E_INSUFFICIENTMEMORY

The stream was not created due to a lack of memory.

STG_E_INVALIDFLAG

The value specified for the grfMode parameter is not a valid STGM Constants value.

STG_E_INVALIDFUNCTION

The specified combination of flags in the grfMode parameter is not supported; for example, when this method is called without the STGM_SHARE_EXCLUSIVE flag.

STG_E_INVALIDNAME

Invalid value for pwcsName.

STG_E_INVALIDPOINTER

The pointer specified for the stream object was invalid.

STG_E_INVALIDPARAMETER

One of the parameters was invalid.

STG_E_REVERTED

The storage object has been invalidated by a revert operation above it in the transaction tree.

STG_E_TOOMANYOPENFILES

The stream was not created because there are too many open files.

Remarks

If a stream with the name specified in the pwcsName parameter already exists and the grfMode parameter includes the STGM_CREATE flag, the existing stream is replaced by a newly created one. Both the destruction of the old stream and the creation of the new stream object are subject to the transaction mode on the parent storage object.

The COM-provided compound file implementation of the IStorage::CreateStream method does not support the following behaviors:

  • The STGM_DELETEONRELEASE flag is not supported.
  • Transacted mode (STGM_TRANSACTED) is not supported for stream objects.
  • Opening the same stream more than once from the same storage is not supported. The STGM_SHARE_EXCLUSIVE sharing-mode flag must be specified in the grfMode parameter.

If the stream already exists and grfMode is set to STGM_FAILIFTHERE, this method fails with the return value STG_E_FILEALREADYEXISTS.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps | Windows Store apps]

Minimum supported server

Windows 2000 Server [desktop apps | Windows Store apps]

Header

Objidl.h

IDL

Objidl.idl

Library

Uuid.lib

DLL

Ole32.dll

IID

IID_IStorage is defined as 0000000B-0000-0000-C000-000000000046

See also

IStorage - Compound File Implementation
IStorage::OpenStream
IStream

 

 

Community Additions

ADD
Show:
© 2015 Microsoft