Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
This function 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 IStorageinterface.
Syntax
WINOLEAPI StgCreateDocfileOnILockBytes( ILockBytes* plkbyt, DWORD grfMode, DWORD reserved, IStorage** ppstgOpen ); |
Parameters
- plkbyt
-
[in] Pointer to the ILockBytesinterface on the underlying byte array object on which to create a compound file.
- grfMode
-
[in] Specifies the access mode to use when opening the new compound file. For more information, see the STGMenumeration.
- reserved
-
[in] Reserved for future use. Set to zero.
- ppstgOpen
-
[out] Pointer to the location of the IStoragepointer on the new storage object.
Return Value
One of the values described in the following table is returned.
Value | Description |
---|---|
S_OK |
Indicates that the compound file was successfully created. |
STG_E_ACCESSDENIED |
Indicates that access was denied because the caller has insufficient permission, or another caller has the file open and locked. |
STG_E_FILEALREADYEXISTS |
Indicates that the compound file already exists and the grfModeparameter is set to STGM_FAILIFTHERE. |
STG_E_INSUFFICIENTMEMORY |
Indicates that the storage object was not created due to a lack of memory. |
STG_E_INVALIDPOINTER |
Indicates a bad pointer was in the pLkbytparameter or the ppStgOpenparameter. |
STG_E_INVALIDFLAG |
Indicates a bad flag combination was in the grfModeparameter. |
STG_E_TOOMANYOPENFILES |
Indicates the storage object was not created due to a lack of file handles. |
STG_E_LOCKVIOLATION |
Indicates that access was denied because another caller has the file open and locked. |
STG_E_SHAREVIOLATION |
Indicates that access was denied because another caller has the file open and locked. |
STG_S_CONVERTED |
Indicates that the compound file was successfully converted. The original byte array object was successfully converted to IStorageformat. |
This function can also return any file system errors, or Win32 errors wrapped in an HRESULT, or ILockBytesinterface error return values.
Remarks
The StgCreateDocfileOnILockBytesand StgOpenStorageOnILockBytesfunctions are not available for the non-desktop compatible implementation by means of CESYSGEN.
The StgCreateDocfileOnILockBytesfunction creates a storage object on top of a byte array object using the COM-provided, compound-file implementation of the IStorageinterface. StgCreateDocfileOnILockBytescan be used to store a document in a relational database. The byte array that is indicated by the pLkbytparameter, which points to the ILockBytesinterface on the object is used for the underlying storage in place of a disk file.
Except for specifying a programmer-provided byte-array object, StgCreateDocfileOnILockBytesis similar to the StgCreateDocfilefunction.
The newly created compound file is opened according to the access modes in the grfModeparameter. 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 IStorageand IStreamtree structure, live in a non-persistent space. Given this capability, there is nothing preventing a document that isstored 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 IStorageinterface for their own outer-level storage. This has the following advantages:
- The storage structure of the document is the same as its
storage structure when it is an embedded object. This reduces 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
IStorageimplementation addresses the problem of how to
commit the changes to the file. An application using the
ILockBytesinterface must handle these issues itself.
- Future file systems will likely implement the
IStorageand
IStreaminterfaces 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 that documents using the
IStorageinterface 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.
Passing into this function any invalid and, under some circumstances, NULL pointers results in unexpected termination of the application.
To determine whether the platform supports this function, see Determining Supported COM APIs.
Requirements
Header | objbase.h |
Library | ole32.lib |
Windows Embedded CE | Windows CE 2.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |