IStream 介面


提供 IStream 介面的 Managed 定義,具有 ISequentialStream 功能。Provides the managed definition of the IStream interface, with ISequentialStream functionality.

public interface class IStream
public interface IStream
type IStream = interface
Public Interface IStream


如需詳細資訊,請參閱 MSDN Library 中的IStreamISequentialStream介面的檔。For more information, see the documentation for the IStream and ISequentialStream interfaces in the MSDN Library.

當機器碼中的 COM 方法傳回 S_OK以外的 HRESULT 時,common language runtime 會擲回例外狀況。The common language runtime throws an exception when a COM method in native code returns an HRESULT other than S_OK. 如需詳細資訊,請參閱 How to: Map HRESULTs and ExceptionsFor more information, see How to: Map HRESULTs and Exceptions.



使用它自己的搜尋指標 (其參考與原始資料流相同的位元組),建立新的資料流物件。Creates a new stream object with its own seek pointer that references the same bytes as the original stream.


確保異動模式 (Transacted Mode) 開啟的資料流物件的任何變更,都會反映在父代 (Parent) 儲存區中。Ensures that any changes made to a stream object that is open in transacted mode are reflected in the parent storage.

CopyTo(IStream, Int64, IntPtr, IntPtr)

從資料流中的目前搜尋指標複製指定數目的位元組到另一個資料流中的目前搜尋指標。Copies a specified number of bytes from the current seek pointer in the stream to the current seek pointer in another stream.

LockRegion(Int64, Int64, Int32)

限制存取資料流中指定的位元組範圍。Restricts access to a specified range of bytes in the stream.

Read(Byte[], Int32, IntPtr)

在目前搜尋指標位置開始,從資料流物件讀取指定數目的位元組到記憶體中。Reads a specified number of bytes from the stream object into memory starting at the current seek pointer.


捨棄從上次 Commit(Int32) 呼叫後對異動資料流的所有變更。Discards all changes that have been made to a transacted stream since the last Commit(Int32) call.

Seek(Int64, Int32, IntPtr)

變更搜尋指標到相對於資料流開頭的新位置、到資料流結尾,或到目前的搜尋指標。Changes the seek pointer to a new location relative to the beginning of the stream, to the end of the stream, or to the current seek pointer.


變更資料流物件的大小。Changes the size of the stream object.

Stat(STATSTG, Int32)

擷取這個資料流的 STATSTG 結構。Retrieves the STATSTG structure for this stream.

UnlockRegion(Int64, Int64, Int32)

移除先前以 LockRegion(Int64, Int64, Int32) 方法限制的位元組範圍之存取限制。Removes the access restriction on a range of bytes previously restricted with the LockRegion(Int64, Int64, Int32) method.

Write(Byte[], Int32, IntPtr)

在目前搜尋指標位置開始,將指定數目的位元組寫入資料流物件中。Writes a specified number of bytes into the stream object starting at the current seek pointer.