SetFilePointerEx function
//z 2014-08-01 13:05:59 L.152'39241 BG57IV3@XCL T4239426005.K.F2462737118[T3,L92,R3,V40]
移动指定文件的文件指针
Syntax
C++
BOOL WINAPI SetFilePointerEx( _In_ HANDLE hFile, _In_ LARGE_INTEGER liDistanceToMove, _Out_opt_ PLARGE_INTEGER lpNewFilePointer, _In_ DWORD dwMoveMethod );
Parameters
-
hFile [in]
-
A handle to the file. The file handle must have been created with the GENERIC_READ or GENERIC_WRITEaccess right. For more information, see File Security and Access Rights.
liDistanceToMove [in]
-
将file pointer 移动多少个字节。负数表示向回移动。
The number of bytes to move the file pointer. A positive value moves the pointer forward in the file and a negative value moves the file pointer backward.
lpNewFilePointer [out, optional]
-
接收新的文件位置的指针变量。
A pointer to a variable to receive the new file pointer. If this parameter is NULL, the new file pointer is not returned.
dwMoveMethod [in]
-
The starting point for the file pointer move. This parameter can be one of the following values.
Value
Meaning
-
FILE_BEGIN
0
从文件开始计算移动的字节
The starting point is zero or the beginning of the file. If this flag is specified, then theliDistanceToMove parameter is interpreted as an unsigned value.-
FILE_CURRENT
1
从当前位置计算文件指针
The start point is the current value of the file pointer.-
FILE_END
2
从文件结束的地方计算文件位置。
The starting point is the current end-of-file position.
文件 handle
Return value
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.
Sample
//z 2014-08-01 13:05:59 L.152'39241 BG57IV3@XCL T4239426005.K.F2462737118[T3,L92,R3,V40]
LARGE_INTEGER newSize;
newSize.QuadPart = _file_offset + _map_size;
//z 将file pointer移动到新的位置
SetFilePointerEx(_hFile, newSize, NULL, FILE_BEGIN);
SetEndOfFile(_hFile);