SetFilePointerEx | windows file api
  ppGGiSfbs6Lj 2023年11月02日 42 0


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]


                文件 handle


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.


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);




【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

ppGGiSfbs6Lj