Home   Index   About
Ultimate Pack


Custom Search
StgCreateDocfileOnILockBytes

Creates and opens a new storage object on top of an ILockBytes instance provided by the caller. The storage object uses the OLE-provided, compound-file implementation for the IStorage interface.

HRESULT StgCreateDocfileOnILockBytes(

ILockBytes * plkbyt,
//Specifies 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

Points to the underlying byte array object on which to create a compound file.

grfMode

Specifies the access mode to use when opening the new compound file. For more information, see the STGM enumeration.

reserved

Reserved for future use; must be zero.

ppstgOpen

Points to the location where the new storage object is placed.

Return Values

S_OK

Indicates the compound file was successfully created.

STG_E_ACCESSDENIED

Indicates the calling process does not have sufficient access. Attempt was made to open an ILockBytes object with permissions that conflict with another current opening of the same object.

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 format.

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 interface for other error return values.

Comments

This function creates a storage object on top of a byte array object using the OLE-provided, compound-file implementation for the IStorage interface. The StgCreateDocfileOnILockBytes function can be used to store a document in a relational database. The byte array indicated by the pLkbyt parameter is used for the underlying storage in place of a disk file.

The StgCreateDocfileOnILockBytes function has almost exactly the same semantics as the StgCreateDocfile function. For more information, see the discussion of 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 persistent space, space that does not ultimately reside in the file system. 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 OLE. However, it is recommended that OLE documents adopt the IStorage interface 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, 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 instance addresses the problem of how to commit the changes to the file. An application using the ILockBytes byte array 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

StgCreateDocfile


Last news from Greatis Software

Nostalgia .Net     Nostalgia .Net     .Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes.  More »

Recommended software for developers

Ultimate Pack for Delphi and C++ Builder     Ultimate Pack     Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price.  More »

Form Designer .Net     Form Designer .Net     Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro!  More »

Print Suite .Net     Print Suite .Net     Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available  More »

Gradient Controls .Net     Gradient Controls .Net     Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available  More »

iGrid     Greatis iGrid     iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors.  More »


All the contacts and projects

Dmitry Vasiliev (just.dmitry)

Related Links

Software for Visual Studio .NET developers
Software for Delphi and C++ Builder developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET

More Online Helps

Win32 Programmer's Reference
Win32 Multimedia Programmer's Reference
OLE Programmer's Reference
Microsoft Windows Pen API Programmer's Reference
Microsoft Windows Sockets 2 Reference
Microsoft Windows Telephony API (TAPI) Programmer's Reference
Unix Manual Pages

Free Tech Secrets ;) Copyright © 2008-2012 Free Tech Secrets ;) greatis just4fun network just4fun