网站首页  词典首页

请输入您要查询的函数:

 

术语 setfilepointerex
释义 SetFilePointerEx
语法:
C++
BOOL WINAPI SetFilePointerEx(
__in HANDLE hFile,
__in LARGE_INTEGER liDistanceToMove,
__out_opt PLARGE_INTEGER lpNewFilePointer,
__in DWORD dwMoveMethod
);
SetFilePointerEx功能
移动指定文件的文件指针。
参数
hFile [in]
阿处理该文件。文件句柄必须已创建的GENERIC_READ或GENERIC_WRITE访问权限。有关更多信息,请参阅文件安全性和访问权限。
liDistanceToMove [in]
的字节数移动文件指针。正值向前移动指针的文件和一个负值移动文件指针落后。
lpNewFilePointer [指出,可选]
对变量的指针,接收新的文件指针。如果该参数为NULL,则新文件指针不会返回。
dwMoveMethod [in]
该文件的指针移动的起点。此参数可以是下列值之一。
ValueMeaning
FILE_BEGIN
0The的出发点是零或文件的开头。如果这个标志被指定,则liDistanceToMove参数被解释为无符号值。
FILE_CURRENT
1The出发点是该文件指针的当前值。
FILE_END
2The的出发点是,当前文件结束的位置。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
备注
该文件指针此函数返回不用于重叠读取和写入操作。若要指定重叠操作偏移,使用OFFSET和OVERLAPPED结构OffsetHigh成员。
您不能使用的处理如管道或通信设备1 nonseeking设备SetFilePointerEx功能。要确定hFile文件类型,使用GetFileType功能。
使用时要小心设置多线程应用程序的文件指针。您必须同步访问共享资源。例如,一个应用程序的线程共享一个文件句柄,更新文件指针,从文件中读取要保护使用临界区对象或互斥对象这个序列。有关这些对象的详细信息,请参阅临界区对象和互斥对象。
如果hFile手柄与FILE_FLAG_NO_BUFFERING标志设置打开一个应用程序可以将文件指针只扇区对齐位置。甲部门的立场是一致的立场是一个卷的扇区大小的整数倍数。应用程序可以通过调用GetDiskFreeSpace函数卷的扇区大小。如果一个应用程序调用SetFilePointerEx与距离对移动价值,因此产生的立场不是部门不结盟和一个句柄,是与FILE_FLAG_NO_BUFFERING打开,该功能失败,而且GetLastError返回ERROR_INVALID_PARAMETER。有关其他信息,请参阅文件缓冲。
请注意,它不是一个错误设置文件指针超出文件末尾的位置。该文件的大小不会增加,直到您调用SetEndOfFile,WriteFile,或WriteFileEx功能。写操作增加了文件的大小文件指针的位置加上书面缓冲区的大小,中间留个字节初始化。
您可以使用SetFilePointerEx来确定一个文件的长度。要做到这一点,使用FILE_END为dwMoveMethod并寻求零的位置。文件偏移返回是该文件的长度。然而,这一做法可以有意想不到的副作用,如未能保存当前文件指针,以便程序可以返回到该位置的影响。它是简单和更安全的使用GetFileSizeEx函数来代替。
您也可以使用SetFilePointerEx来查询当前文件指针的位置。要做到这一点,指定一个FILE_CURRENT移动方法和零的距离。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinBase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
文件管理函数
GetDiskFreeSpaceEx
GetFileSizeEx
GetFileType
SetEndOfFile
WriteFile
WriteFileEx
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年9月3日
==英文原文==SetFilePointerEx Function
Moves the file pointer of the specified file.
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_WRITE access right. For more information, see File Security and Access Rights .
liDistanceToMove [in]
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.
ValueMeaning
FILE_BEGIN
0The starting point is zero or the beginning of the file. If this flag is specified, then the liDistanceToMove parameter is interpreted as an unsigned value.
FILE_CURRENT
1The start point is the current value of the file pointer.
FILE_END
2The 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 .
Remarks
The file pointer returned by this function is not used for overlapped read and write operations. To specify the offset for overlapped operations, use the Offset and OffsetHigh members of the OVERLAPPED structure.
You cannot use the SetFilePointerEx function with a handle to a nonseeking device such as a pipe or a communications device. To determine the file type for hFile, use the GetFileType function.
Use caution when setting the file pointer in a multithreaded application. You must synchronize access to shared resources. For example, an application whose threads share a file handle, update the file pointer, and read from the file must protect this sequence by using a critical section object or a mutex object. For more information about these objects, see Critical Section Objects and Mutex Objects .
If the hFile handle was opened with the FILE_FLAG_NO_BUFFERING flag set, an application can move the file pointer only to sector-aligned positions. A sector-aligned position is a position that is a whole number multiple of the volume's sector size. An application can obtain a volume's sector size by calling the GetDiskFreeSpace function. If an application calls SetFilePointerEx with distance-to-move values that result in a position that is not sector-aligned and a handle that was opened with FILE_FLAG_NO_BUFFERING, the function fails, and GetLastError returns ERROR_INVALID_PARAMETER. For additional information, see File Buffering .
Note that it is not an error to set the file pointer to a position beyond the end of the file. The size of the file does not increase until you call the SetEndOfFile , WriteFile , or WriteFileEx function. A write operation increases the size of the file to the file pointer position plus the size of the buffer written, leaving the intervening bytes uninitialized.
You can use SetFilePointerEx to determine the length of a file. To do this, use FILE_END for dwMoveMethod and seek to location zero. The file offset returned is the length of the file. However, this practice can have unintended side effects, such as failure to save the current file pointer so that the program can return to that location. It is simpler and safer to use the GetFileSizeEx function instead.
You can also use SetFilePointerEx to query the current file pointer position. To do this, specify a move method of FILE_CURRENT and a distance of zero.
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinBase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
File Management Functions
GetDiskFreeSpaceEx
GetFileSizeEx
GetFileType
SetEndOfFile
WriteFile
WriteFileEx
Send comments about this topic to Microsoft
Build date: 9/3/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa365542(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:15:55