网站首页  词典首页

请输入您要查询的函数:

 

术语 flushfilebuffers
释义 FlushFileBuffers
语法:
C++
BOOL WINAPI FlushFileBuffers(
__in HANDLE hFile
);
FlushFileBuffers函数
刷新指定文件的缓冲区,并导致所有缓冲的数据写入到一个文件。
参数
hFile [in]
一个句柄,打开的文件。
文件句柄必须有GENERIC_WRITE访问权限。有关更多信息,请参阅文件安全性和访问权限。
如果hFile是一个句柄通讯设备,功能只刷新发送缓冲区。
如果hFile是一个句柄的命名管道服务器端,该函数不返回到客户端已经从管道中读取所有缓冲的数据。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
函数失败如果hFile是一个句柄到控制台输出。这是因为控制台输出不进行缓冲。该函数返回FALSE,并GetLastError返回出现ERROR_INVALID_HANDLE。
备注
通常,WriteFile和WriteFileEx函数将数据写入内部缓冲区,并且操作系统写入到磁盘或通信管定期。该FlushFileBuffers函数将一个指定的文件的设备或管所有的缓冲信息。
由于磁盘缓存系统内的相互作用,FlushFileBuffers函数可以低效写入时,在每一个磁盘驱动器设备时使用的许多写入正在执行分开。如果应用程序正在执行多个写入磁盘,也需要确保关键数据被写入一直有媒体报道,应用程序应该使用缓冲I / O,而不是频繁调用FlushFileBuffers。要打开一个文件的缓冲I / O,请与FILE_FLAG_NO_BUFFERING和FILE_FLAG_WRITE_THROUGH全方位旗帜CreateFile函数。这可以防止被缓存的文件内容,并与每个刷新数据写入到磁盘。有关更多信息,请参阅CreateFile。
要刷新卷上的所有打开的文件,与句柄调用FlushFileBuffers量。调用者必须具有管理权限。有关更多信息,请运行特权。
当打开一个CreateFile的lpFileName串量应以下形式:\\ \\。\\ x:或\\ \\?\\的Volume(GUID)。不要使用量的名字反斜杠结尾,因为这显示驱动器的根目录。
实例
有关示例,请参见多线程管道服务器。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinBase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
CreateFile
文件管理函数
WriteFile
WriteFileEx
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年9月3日
==英文原文==FlushFileBuffers Function
Flushes the buffers of a specified file and causes all buffered data to be written to a file.
Syntax
C++
BOOL WINAPI FlushFileBuffers(
__in HANDLE hFile
);
Parameters
hFile [in]
A handle to the open file.
The file handle must have the GENERIC_WRITE access right. For more information, see File Security and Access Rights .
If hFile is a handle to a communications device, the function only flushes the transmit buffer.
If hFile is a handle to the server end of a named pipe, the function does not return until the client has read all buffered data from the pipe.
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 .
The function fails if hFile is a handle to the console output. That is because the console output is not buffered. The function returns FALSE, and GetLastError returns ERROR_INVALID_HANDLE.
Remarks
Typically the WriteFile and WriteFileEx functions write data to an internal buffer that the operating system writes to a disk or communication pipe on a regular basis. The FlushFileBuffers function writes all the buffered information for a specified file to the device or pipe.
Due to disk caching interactions within the system, the FlushFileBuffers function can be inefficient when used after every write to a disk drive device when many writes are being performed separately. If an application is performing multiple writes to disk and also needs to ensure critical data is written to persistent media, the application should use unbuffered I/O instead of frequently calling FlushFileBuffers. To open a file for unbuffered I/O, call the CreateFile function with the FILE_FLAG_NO_BUFFERING and FILE_FLAG_WRITE_THROUGH flags. This prevents the file contents from being cached and flushes the metadata to disk with each write. For more information, see CreateFile .
To flush all open files on a volume, call FlushFileBuffers with a handle to the volume. The caller must have administrative privileges. For more information, see Running with Special Privileges .
When opening a volume with CreateFile, the lpFileName string should be the following form: \\\\.\\x: or \\\\?\\Volume{GUID}. Do not use a trailing backslash in the volume name, because that indicates the root directory of a drive.
Examples
For an example, see Multithreaded Pipe Server .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinBase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
CreateFile
File Management Functions
WriteFile
WriteFileEx
Send comments about this topic to Microsoft
Build date: 9/3/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa364439(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 11:29:29