这个接口是一个字节数组对象上实现由一些物理存储,如磁盘文件,全局内存或数据库。
它使用一个组件对象模型(COM)复合文件存储对象给其根存储访问物理设备,而隔离根存储访问物理存储的细节。
大多数应用程序不会实现 ILockBytes 因为COM接口提供了实现最常见的一种情况:
基于文件的实现 如果你所说的 StgCreateDocfile 函数创建一个复合文件存储对象,它包含的一个实现ILockBytes 这是关联到一个字节数组存储在一个物理磁盘文件。
复合文件存储对象调用 ILockBytes 方法。 你不叫他们直接在这个实现。
有些情况下,这将是有用的为应用程序提供它自己的 ILockBytes 实现。
例如,一个数据库应用程序可以实现 ILockBytes 创建一个字节数组对象支持的存储的关系表。 然而,强烈建议您使用COM-provided实现。
讨论了使用COM实现的优点,而不是创建自己的看到 StgCreateDocfileOnILockBytes 函数,它创建了一个复合文件存储对象的调用者提供的字节数组对象。
的 ILockBytes COM的实现方法 IStorage 和 IStream 复合文件对象的接口。
除非你正在实施 IStorage 和 IStream ,你不需要打电话 ILockBytes 直接的方法。
如果你写你自己的 ILockBytes 实现,您可以使用 StgCreateDocfileOnILockBytes 函数创建一个复合文件存储对象支持的实现 ILockBytes 。
确定平台是否支持这个接口,明白了 Determining Supported COM APIs.
This interface is implemented on a byte array object that is backed by some physical storage, such as a disk file, global memory, or a database.
It is used by a Component Object Model (COM) compound file storage object to give its root storage access to the physical device, while isolating the root storage from the details of accessing the physical storage.
Most applications will not implement the ILockBytes interface because COM provides implementations for one of the most common situations:
File-based implementation If you call the StgCreateDocfile function to create a compound file storage object, it contains an implementation of ILockBytes that is associated with a byte array stored in a physical disk file.
The compound file storage object calls the ILockBytes methods. You do not call them directly in this implementation.
There are situations in which it would be useful for an application to provide its own ILockBytes implementation.
For example, a database application could implement ILockBytes to create a byte array object backed by the storage of its relational tables. However, it is strongly recommended that you use the COM-provided implementations.
For a discussion of the advantages of using the COM implementations rather than creating your own, see the StgCreateDocfileOnILockBytes function, which creates a compound file storage object on top of a caller-provided byte array object.
The ILockBytes methods are called by the COM implementations of the IStorage and IStream interfaces on the compound file object.
Unless you are implementing IStorage and IStream, you would not need to call ILockBytes methods directly.
If you write your own ILockBytes implementation, you can use the StgCreateDocfileOnILockBytes function to create a compound file storage object backed by your implementation of ILockBytes.
The following table shows the methods for this interface in alphabetical order.
Method | Description |
---|---|
Ensures that any internal buffers maintained by the byte array object are written out to the backing storage. |
|
Restricts access to a specified range of bytes in the array. |
|
Reads a specified number of bytes starting at a specified offset from the beginning of the array. |
|
Changes the size of the byte array. |
|
Retrieves a STATSTG structure for this byte array object. |
|
Removes the access restriction on a range of bytes previously restricted with ILockBytes::LocRegion. |
|
Writes a specified number of bytes to a specified location in the array. |
To determine whether the platform supports this interface, see Determining Supported COM APIs.