Upravit

Sdílet prostřednictvím


IStream::Seek method (objidl.h)

The Seek method changes the seek pointer to a new location. The new location is relative to either the beginning of the stream, the end of the stream, or the current seek pointer.

Syntax

HRESULT Seek(
  [in]  LARGE_INTEGER  dlibMove,
  [in]  DWORD          dwOrigin,
  [out] ULARGE_INTEGER *plibNewPosition
);

Parameters

[in] dlibMove

The 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 a signed value.

[in] dwOrigin

The origin for the displacement specified in dlibMove. The origin can be the beginning of the file (STREAM_SEEK_SET), the current seek pointer (STREAM_SEEK_CUR), or the end of the file (STREAM_SEEK_END). For more information about values, see the STREAM_SEEK enumeration.

[out] plibNewPosition

A 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. In this case, this method does not provide the new seek pointer.

Return value

This method can return one of these values.

Return code Description
S_OK The seek pointer was successfully adjusted.
E_PENDING Asynchronous Storage only: Part or all of the stream data is currently unavailable.
STG_E_INVALIDPOINTER Indicates that plibNewPosition points to invalid memory, because plibNewPosition is not read.
STG_E_INVALIDFUNCTION The dwOrigin parameter contains an invalid value, or the dlibMove parameter contains a bad offset value. For example, the result of the seek pointer is a negative offset value.
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 read and write operations can be performed 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 write operations, as the stream byte range will be extended to the new seek position immediately before the write is complete.

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 0 so that the seek pointer is not changed. The current seek pointer is returned in the plibNewPosition parameter.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps | UWP apps]
Minimum supported server Windows 2000 Server [desktop apps | UWP apps]
Target Platform Windows
Header objidl.h
Library Uuid.lib
DLL Ole32.dll

See also

ISequentialStream::Read

ISequentialStream::Write

IStream - Compound File Implementation

STREAM_SEEK