SetFilePointerEx | windows file api

7 篇文章 0 订阅
6 篇文章 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);


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值