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 COM-provided, compound-file implementation for the IStorage interface.
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
);
This function can also return any file system errors or Win32 errors wrapped in an HRESULT.
This function can also return any file system errors, or Win32 errors wrapped in an HRESULT, or ILockBytes interface error return values.
The StgCreateDocfileOnILockBytes function creates a storage object on top of a byte array object using the COM-provided, compound-file implementation of the IStorage interface. StgCreateDocfileOnILockBytes can be used to store a document in a relational database. The byte array (indicated by the pLkbyt parameter, which points to the ILockBytes interface on the object) is used for the underlying storage in place of a disk file.
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 tree structure) live in a non-persistent space. Given this capability, there is nothing preventing a document that is stored in a file from using this facility. For example, a container might do this to minimize the impact on its file format caused by adopting COM. However, it is recommended that COM documents adopt the IStorage interface for their own outer-level storage. This has the following advantages:
Windows CE: The StgCreateDocfileOnILockBytes and StgOpenStorageOnILockBytes functions are not available for the non-desktop compatible implementation via CESYSGEN.
Passing into this function any invalid and, under some circumstances, NULL pointers will result in unexpected termination of the application. For more information about handling exceptions, see Programming Considerations.
Windows NT: Use version 3.1 or later.
Windows: Use Windows 95 or later.
Windows CE: Use version 2.0 or later.
Header: Declared in objbase.h.
Import Library: Included as a resource in ole32.dll.