次の方法で共有


CreateStreamOnHGlobal (Compact 2013)

3/26/2014

This function creates a stream object stored in global memory.

Syntax

WINOLEAPI CreateStreamOnHGlobal(
  HGLOBAL hGlobal,
  BOOL fDeleteOnRelease,
  LPSTREAM* ppstm
);

Parameters

  • hGlobal
    [in] Memory handle allocated by the GlobalAlloc function.

    The handle must be allocated as movable and nondiscardable.

    If the handle is to be shared between processes, it must also be allocated as shared.

    New handles should be allocated with a size of zero.

    If hGlobal is NULL, the CreateStreamOnHGlobal function internally allocates a new shared memory block of size zero.

  • fDeleteOnRelease
    [in] Whether the underlying handle for this stream object should be automatically freed when the stream object is released.
  • ppstm
    [out] Address of the IStream* pointer variable that receives the interface pointer to the new stream object.

    Its value cannot be NULL.

Return Value

The following HRESULT values can be returned.

Value

Description

S_OK

The stream object was created.

E_NOINTERFACE

The specified interface is not supported.

E_OUTOFMEMORY

The function failed.

Remarks

The CreateStreamOnHGlobal function creates a stream object in memory that supports the OLE implementation of the IStream interface.

The returned stream object

  • Supports reading and writing
  • Is not transacted
  • Does not support locking

The initial contents of the stream are the current contents of the memory block provided in the hGlobal parameter. If the hGlobal parameter is NULL, this function internally allocates memory.

The current contents of the memory block are undisturbed by the creation of the stream object. Thus, you can use this function to open an existing stream in memory.

If the logical size of the stream is important, follow the call to this function with a call to the IStream::SetSize method.

After you create the stream object with CreateStreamOnHGlobal, you can call GetHGlobalFromStream to get the global memory handle associated with the stream object.

To determine whether the platform supports this function, see Determining Supported COM APIs.

Requirements

Header

ole2.h

Library

ole32.lib

See Also

Tasks

Determine Supported COM APIs

Reference

OLE Functions
Automation Functions
IStream
IStream
IStream::SetSize
GetHGlobalFromStream