title | description | ms.date | f1_keywords | helpviewer_keywords | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
COleStreamFile Class |
Learn more about: COleStreamFile Class |
11/04/2016 |
|
|
Represents a stream of data (IStream
) in a compound file as part of OLE Structured Storage.
class COleStreamFile : public CFile
Name | Description |
---|---|
COleStreamFile::COleStreamFile | Constructs a COleStreamFile object. |
Name | Description |
---|---|
COleStreamFile::Attach | Associates a stream with the object. |
COleStreamFile::CreateMemoryStream | Creates a stream from global memory and associates it with the object. |
COleStreamFile::CreateStream | Creates a stream and associates it with the object. |
COleStreamFile::Detach | Disassociates the stream from the object. |
COleStreamFile::GetStream | Returns the current stream. |
COleStreamFile::OpenStream | Safely opens a stream and associates it with the object. |
An IStorage
object must exist before the stream can be opened or created unless it is a memory stream.
COleStreamFile
objects are manipulated exactly like CFile objects.
For more information about manipulating streams and storages, see the article Containers: Compound Files.
For more information, see IStream and IStorage in the Windows SDK.
COleStreamFile
Header: afxole.h
Associates the supplied OLE stream with the COleStreamFile
object.
void Attach(LPSTREAM lpStream);
lpStream
Points to the OLE stream (IStream
) to be associated with the object. Cannot be NULL.
The object must not already be associated with an OLE stream.
For more information, see IStream in the Windows SDK.
Creates a COleStreamFile
object.
COleStreamFile(LPSTREAM lpStream = NULL);
lpStream
Pointer to the OLE stream to be associated with the object.
If lpStream is NULL, the object is not associated with an OLE stream, otherwise, the object is associated with the supplied OLE stream.
For more information, see IStream in the Windows SDK.
Safely creates a new stream out of global, shared memory where a failure is a normal, expected condition.
BOOL CreateMemoryStream(CFileException* pError = NULL);
pError
Points to a CFileException object or NULL that indicates the completion status of the create operation. Supply this parameter if you want to monitor possible exceptions generated by attempting to create the stream.
Nonzero if the stream is created successfully; otherwise 0.
The memory is allocated by the OLE subsystem.
For more information, see CreateStreamOnHGlobal in the Windows SDK.
Safely creates a new stream in the supplied storage object where a failure is a normal, expected condition.
BOOL CreateStream(
LPSTORAGE lpStorage,
LPCTSTR lpszStreamName,
DWORD nOpenFlags = modeReadWrite|shareExclusive|modeCreate,
CFileException* pError = NULL);
lpStorage
Points to the OLE storage object that contains the stream to be created. Cannot be NULL.
lpszStreamName
Name of the stream to be created. Cannot be NULL.
nOpenFlags
Access mode to use when opening the stream. Exclusive, read/write, and create modes are used by default. For a complete list of the available modes, see CFile::CFile.
pError
Points to a CFileException object or NULL. Supply this parameter if you want to monitor possible exceptions generated by attempting to create the stream.
Nonzero if the stream is created successfully; otherwise 0.
A file exception will be thrown if the open fails and pError is not NULL.
For more information, see IStorage::CreateStream in the Windows SDK.
Disassociates the stream from the object without closing the stream.
LPSTREAM Detach();
A pointer to the stream (IStream
) that was associated with the object.
The stream must be closed in some other fashion before the program terminates.
For more information, see IStream in the Windows SDK.
Call this function to return a pointer to current stream.
IStream* GetStream() const;
A pointer to the current stream interface ( IStream).
Opens an existing stream.
BOOL OpenStream(
LPSTORAGE lpStorage,
LPCTSTR lpszStreamName,
DWORD nOpenFlags = modeReadWrite|shareExclusive,
CFileException* pError = NULL);
lpStorage
Points to the OLE storage object that contains the stream to be opened. Cannot be NULL.
lpszStreamName
Name of the stream to be opened. Cannot be NULL.
nOpenFlags
Access mode to use when opening the stream. Exclusive and read/write modes are used by default. For the complete list of the available modes, see CFile::CFile.
pError
Points to a CFileException object or NULL. Supply this parameter if you want to monitor possible exceptions generated by attempting to open the stream.
Nonzero if the stream is opened successfully; otherwise 0.
A file exception will be thrown if the open fails and pError is not NULL.
For more information, see IStorage::OpenStream in the Windows SDK.