InternetSetFilePointer

This function sets a file position for InternetReadFile. This is a synchronous call; however, subsequent calls to InternetReadFile might block or return pending if the data is not available from the cache and the server does not support random access.

At a Glance

Header file: Wininet.h
Windows CE versions: 2.12 and later

Syntax

DWORD InternetSetFilePointer (HINTERNET hFile,
LONG
lDistanceToMove, PVOID pReserved, DWORD dwMoveMethod, DWORD dwContext);

Parameters

hFile

[in] Valid HINTERNET handle returned from a previous call to InternetOpenUrl (on an HTTP or HTTPS URL) or HttpOpenRequest (using the GET or HEAD method and passed to HttpSendRequest or HttpSendRequestEx). This handle must not have been created with the INTERNET_FLAG_DONT_CACHE or INTERNET_FLAG_NO_CACHE_WRITE value set.

lDistanceToMove

[in] Long integer value that contains the number of bytes to move the file pointer. A positive value moves the pointer forward in the file; a negative value moves it backward.

pReserved

[in] Reserved. Must be set to NULL.

dwMoveMethod

[in] Unsigned long integer value that indicates the starting point for the file pointer move. Can be one of the following values:

Value Description
FILE_BEGIN Starting point is zero or the beginning of the file. If FILE_BEGIN is specified, lDistanceToMove is interpreted as an unsigned location for the new file pointer.
FILE_CURRENT Current value of the file pointer is the starting point.
FILE_END Current end-of-file position is the starting point. This method fails if the content length is unknown.

dwContext

Reserved. Must be set to zero.

Return Values

Returns the current file position if the function succeeds, or –1 otherwise.

Remarks

This function cannot be used once the end of file has been reached by InternetReadFile.

For HINTERNET handles created by HttpOpenRequest and sent by HttpSendRequestEx, a call to HttpEndRequest must be made on the handle before this function is used.

This function cannot be used reliably if the content length is unknown, and with chunked transfers.

See Also

InternetReadFile