ILockBytes Windows Mobile 6.5
ILockBytes
Windows Mobile 6.5 https://msdn.microsoft.com/zh-cn/library/aa911496(en-us,MSDN.10).aspx這個(gè)接口是一個(gè)字節(jié)數(shù)組對(duì)象上實(shí)現(xiàn)由一些物理存儲(chǔ),如磁盤(pán)文件,全局內(nèi)存或數(shù)據(jù)庫(kù)。
它使用一個(gè)組件對(duì)象模型(COM)復(fù)合文件存儲(chǔ)對(duì)象給其根存儲(chǔ)訪問(wèn)物理設(shè)備,而隔離根存儲(chǔ)訪問(wèn)物理存儲(chǔ)的細(xì)節(jié)。
什么時(shí)候?qū)崿F(xiàn)大多數(shù)應(yīng)用程序不會(huì)實(shí)現(xiàn)?ILockBytes?因?yàn)镃OM接口提供了實(shí)現(xiàn)最常見(jiàn)的一種情況:
基于文件的實(shí)現(xiàn)?如果你所說(shuō)的?StgCreateDocfile?函數(shù)創(chuàng)建一個(gè)復(fù)合文件存儲(chǔ)對(duì)象,它包含的一個(gè)實(shí)現(xiàn)ILockBytes?這是關(guān)聯(lián)到一個(gè)字節(jié)數(shù)組存儲(chǔ)在一個(gè)物理磁盤(pán)文件。
復(fù)合文件存儲(chǔ)對(duì)象調(diào)用?ILockBytes?方法。 你不叫他們直接在這個(gè)實(shí)現(xiàn)。
有些情況下,這將是有用的為應(yīng)用程序提供它自己的?ILockBytes?實(shí)現(xiàn)。
例如,一個(gè)數(shù)據(jù)庫(kù)應(yīng)用程序可以實(shí)現(xiàn)?ILockBytes?創(chuàng)建一個(gè)字節(jié)數(shù)組對(duì)象支持的存儲(chǔ)的關(guān)系表。 然而,強(qiáng)烈建議您使用COM-provided實(shí)現(xiàn)。
討論了使用COM實(shí)現(xiàn)的優(yōu)點(diǎn),而不是創(chuàng)建自己的看到?StgCreateDocfileOnILockBytes?函數(shù),它創(chuàng)建了一個(gè)復(fù)合文件存儲(chǔ)對(duì)象的調(diào)用者提供的字節(jié)數(shù)組對(duì)象。
什么時(shí)候使用的?ILockBytes?COM的實(shí)現(xiàn)方法?IStorage?和?IStream?復(fù)合文件對(duì)象的接口。
除非你正在實(shí)施?IStorage?和?IStream?,你不需要打電話?ILockBytes?直接的方法。
如果你寫(xiě)你自己的?ILockBytes?實(shí)現(xiàn),您可以使用?StgCreateDocfileOnILockBytes?函數(shù)創(chuàng)建一個(gè)復(fù)合文件存儲(chǔ)對(duì)象支持的實(shí)現(xiàn)?ILockBytes?。
方法下面的表顯示了這個(gè)接口的方法按字母順序排列的。
?
| 沖洗 | 確保維護(hù)的任何內(nèi)部緩沖區(qū)字節(jié)數(shù)組對(duì)象寫(xiě)入到存儲(chǔ)支持。 |
| LockRegion | 限制訪問(wèn)指定范圍的字節(jié)數(shù)組。 |
| ReadAt | 讀取指定的字節(jié)數(shù)在指定偏移位置開(kāi)始從一開(kāi)始的數(shù)組。 |
| SetSize | 字節(jié)數(shù)組的大小變化。 |
| 統(tǒng)計(jì) | 檢索?STATSTG?這個(gè)字節(jié)數(shù)組對(duì)象結(jié)構(gòu)。 |
| UnlockRegion | 刪除之前限制的訪問(wèn)限制在一個(gè)范圍的字節(jié)?ILockBytes:LocRegion?。 |
| WriteAt | 寫(xiě)入指定數(shù)量的字節(jié)數(shù)組中指定的位置。 |
確定平臺(tái)是否支持這個(gè)接口,明白了?Determining Supported COM APIs.
Requirements| 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.
When to ImplementMost 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.
When to UseThe?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.
MethodsThe following table shows the methods for this interface in alphabetical order.
?
| 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.
Requirements| 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 |
總結(jié)
以上是生活随笔為你收集整理的ILockBytes Windows Mobile 6.5的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: zabbix监控实践解析(历史记录附近乱
- 下一篇: CCF NOI1150 确定进制