次の方法で共有


IStream::Seek (Compact 2013)

3/26/2014

This method changes the seek pointer to a new location relative to the current seek pointer or the beginning or end of the stream.

Syntax

HRESULT Seek( 
  ULARGE_INTEGER dlibMove, 
  DWORD dwOrigin, 
  ULARGE_INTEGER plibNewPosition 
);

Parameters

  • dlibMove
    [in] Displacement to be added to the location indicated by the dwOrigin parameter. If dwOrigin is STREAM_SEEK_SET, this is interpreted as an unsigned value rather than signed.
  • dwOrigin
    [in] Origin for the displacement specified in dlibMove. The origin can be the beginning of the file, the current seek pointer, or the end of the file.
  • plibNewPosition
    [out] Pointer to the location where this method writes the value of the new seek pointer from the beginning of the stream.

    You can set this pointer to NULL to indicate that you are not interested in this value. In this case, this method does not provide the new seek pointer.

Return Value

The following table shows the return values for this method.

Value

Description

S_OK

The seek pointer has been successfully adjusted.

E_PENDING

Asynchronous Storage only: Part or all of the stream's data is currently unavailable.

STG_E_INVALIDPOINTER

The value of the plibNewPosition parameter is not valid.

STG_E_INVALIDFUNCTION

The value of the dwOrigin parameter is not valid.

STG_E_REVERTED

The object has been invalidated by a revert operation above it in the transaction tree.

Remarks

IStream::Seek changes the seek pointer so that subsequent reads and writes can take place at a different location in the stream object.

It is an error to seek before the beginning of the stream.

It is not, however, an error to seek past the end of the stream. Seeking past the end of the stream is useful for subsequent writes, as the stream will at that time be extended to the seek position immediately before the write is done.

You can also use this method to obtain the current value of the seek pointer by calling this method with the dwOrigin parameter set to STREAM_SEEK_CUR and the dlibMove parameter set to zero so the seek pointer is not changed.

The current seek pointer is returned in the plibNewPosition parameter.

To determine whether the platform supports this interface, see Determining Supported COM APIs.

Requirements

Header

objidl.h,
objidl.idl

Library

ole32.lib,
uuid.lib

See Also

Reference

IStream