StgCreateDocfileOnILockBytes
Creates and
opens a new compound file storage object on top of a byte array object provided
by the caller. The storage object supports the OLE-provided, compound-file
implementation for the IStorage
WINOLEAPI StgCreateDocfileOnILockBytes(
ILockBytes * plkbyt, |
//Points
to the ILockBytes interface on the byte array object |
DWORD grfMode, |
//Specifies
the access mode |
DWORD reserved, |
//Reserved;
must be zero |
IStorage ** ppstgOpen |
//Points
to location for returning the new storage object |
); |
|
Parameters
plkbyt
[in] Points
to the ILockBytes
grfMode
[in]
Specifies the access mode to use when opening the new compound file. For more
information, see the STGM
reserved
[in] Reserved
for future use; must be zero.
ppstgOpen
[out] Points
to the location of the IStorage pointer on the new storage object.
Return Values
S_OK
Indicates the
compound file was successfully created.
STG_E_ACCESSDENIED
Access denied
because the caller has insufficient permission, or another caller has the file
open and locked.
STG_E_LOCKVIOLATION
Access denied
because another caller has the file open and locked.
STG_E_FILEALREADYEXISTS
Indicates the
compound file already exists and the grfMode parameter is set to
STGM_FAILIFTHERE.
STG_S_CONVERTED
Indicates the
compound file was successfully converted. The original byte array object was
successfully converted to IStorage
STG_E_INSUFFICIENTMEMORY
Indicates the
storage object was not created due to a lack of memory.
STG_E_INVALIDPOINTER
Indicates a
bad pointer was in the pLkbyt parameter or the ppStgOpen
parameter.
STG_E_INVALIDFLAG
Indicates a
bad flag combination was in the grfMode parameter.
STG_E_TOOMANYOPENFILES
Indicates the
storage object was not created due to a lack of file handles.
See also any
file system errors for other error return values.
See also the ILockBytes
Remarks
The StgCreateDocfileOnILockBytes
function creates a storage object on top of a byte array object using the
OLE-provided, compound-file implementation of the IStorage
Except for
specifying a programmer-provided byte-array object, StgCreateDocfileOnILockBytes
is similar to the StgCreateDocfile function. For more information, refer
to StgCreateDocfile
The newly
created compound file is opened according to the access modes in the grfMode
parameter. For conversion purposes, the file is always considered to already
exist. As a result, it is not useful to use the STGM_FAILIFTHERE value, because
it always causes an error to be returned. However, STGM_CREATE and STGM_CONVERT
are both still useful.
The ability
to build a compound file on top of a byte array object is provided to support
having the data (underneath an IStorage and IStream
The storage structure of the
document is the same as its storage structure when it is an embedded object,
reducing the number of cases the application needs to handle.
One can write tools to access
the OLE embeddings and links within the document without special knowledge of
the document s file format. An example of such a tool is a copy utility that
copies all the documents included in a container containing linked objects. A
copy utility like this needs access to the contained links to determine the
extent of files to be copied.
The IStorage implementation addresses
the problem of how to commit the changes to the file. An application using the ILockBytes interface must handle
these issues itself.
Future file systems will likely
implement the IStorage and IStream interfaces as their native abstractions, rather
than layer on top of a byte array as is done in compound files. Such a file
system could be built so documents using the IStorage interface as their
outer level containment structure would get an automatic efficiency gain by
having the layering flattened when files are saved on the new file system.
See Also