首页 > 代码库 > ILockBytes Windows Mobile 6.5
ILockBytes Windows Mobile 6.5
ILockBytes
这个接口是一个字节数组对象上实现由一些物理存储,如磁盘文件,全局内存或数据库。
它使用一个组件对象模型(COM)复合文件存储对象给其根存储访问物理设备,而隔离根存储访问物理存储的细节。
大多数应用程序不会实现 ILockBytes 因为COM接口提供了实现最常见的一种情况:
基于文件的实现 如果你所说的 StgCreateDocfile 函数创建一个复合文件存储对象,它包含的一个实现ILockBytes 这是关联到一个字节数组存储在一个物理磁盘文件。
复合文件存储对象调用 ILockBytes 方法。 你不叫他们直接在这个实现。
有些情况下,这将是有用的为应用程序提供它自己的 ILockBytes 实现。
例如,一个数据库应用程序可以实现 ILockBytes 创建一个字节数组对象支持的存储的关系表。 然而,强烈建议您使用COM-provided实现。
讨论了使用COM实现的优点,而不是创建自己的看到 StgCreateDocfileOnILockBytes 函数,它创建了一个复合文件存储对象的调用者提供的字节数组对象。
的 ILockBytes COM的实现方法 IStorage 和 IStream 复合文件对象的接口。
除非你正在实施 IStorage 和 IStream ,你不需要打电话 ILockBytes 直接的方法。
如果你写你自己的 ILockBytes 实现,您可以使用 StgCreateDocfileOnILockBytes 函数创建一个复合文件存储对象支持的实现 ILockBytes 。
下面的表显示了这个接口的方法按字母顺序排列的。
方法 | 描述 |
---|---|
冲洗 | 确保维护的任何内部缓冲区字节数组对象写入到存储支持。 |
LockRegion | 限制访问指定范围的字节数组。 |
ReadAt | 读取指定的字节数在指定偏移位置开始从一开始的数组。 |
SetSize | 字节数组的大小变化。 |
统计 | 检索 STATSTG 这个字节数组对象结构。 |
UnlockRegion | 删除之前限制的访问限制在一个范围的字节 ILockBytes:LocRegion 。 |
WriteAt | 写入指定数量的字节数组中指定的位置。 |
确定平台是否支持这个接口,明白了 Determining Supported COM APIs.
Header | objidl.h, objidl.idl |
Library | ole32.lib, uuid.lib |
Windows Embedded CE | Windows CE 2.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |
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 |
---|---|
Flush | Ensures that any internal buffers maintained by the byte array object are written out to the backing storage. |
LockRegion | Restricts access to a specified range of bytes in the array. |
ReadAt | Reads a specified number of bytes starting at a specified offset from the beginning of the array. |
SetSize | Changes the size of the byte array. |
Stat | Retrieves a STATSTG structure for this byte array object. |
UnlockRegion | Removes the access restriction on a range of bytes previously restricted with ILockBytes::LocRegion. |
WriteAt | 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.
Header | objidl.h, objidl.idl |
Library | ole32.lib, uuid.lib |
Windows Embedded CE | Windows CE 2.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |
ILockBytes Windows Mobile 6.5