The SetFilePointer function moves the file pointer of an open file.
HANDLE hFile, // handle of file
LONG lDistanceToMove, // number of bytes to move file pointer
// pointer to high-order DWORD of
// distance to move
DWORD dwMoveMethod // how to move
Handle to the file whose file pointer is to be moved. The file handle must have been created with GENERIC_READ or GENERIC_WRITE access to the file.
Low-order 32 bits of a signed value that specifies the number of bytes to move the file pointer. If lpDistanceToMoveHigh is not NULL, lpDistanceToMoveHigh and lDistanceToMove form a single 64-bit signed value that specifies the distance to move. If lpDistanceToMoveHigh is NULL, lDistanceToMove is a 32-bit signed value. A positive value for lDistanceToMove moves the file pointer forward in the file, and a negative value moves the file pointer backward.
Pointer to the high-order 32 bits of the signed 64-bit distance to move. If you do not need the high-order 32 bits, this pointer may be NULL. When non-NULL, this parameter also receives the high-order DWORD of the new value of the file pointer. For more information, see the Remarks section later in this topic.
Starting point for the file pointer move. This parameter can be one of the following values. Value Meaning
FILE_BEGIN The starting point is zero or the beginning of the file.
FILE_CURRENT The starting point is the current value of the file pointer.
FILE_END The starting point is the current end-of-file position.
The SetEndOfFile function moves the end-of-file (EOF) position for the specified file to the current position of the file pointer.
HANDLE hFile // handle of file whose EOF is to be set
Handle to the file to have its EOF position moved. The file handle must have been created with GENERIC_WRITE access to the file.
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
This function can be used to truncate or extend a file. If the file is extended, the contents of the file between the old EOF position and the new position are not defined.
If you called CreateFileMapping to create a file-mapping object for hFile, you must first call UnmapViewOfFile to unmap all views and call CloseHandle to close the file-mapping object before you can call SetEndOfFile.