Tech Journal Back to Tech Journal

How can I flush all the buffers of a disk in Windows?

To flush all buffers for a volume, call FlushFileBuffers with a handle to the volume. Must be Admin priv, When opening a volume with CreateFile, the lpFileName string should be of the form \\.\<x>: or \\?\Volume{GUID}. Do not use a trailing backslash in the volume name; this would indicate the root directory of the drive.

This is easily used to write an application to flush loaded USB media.


[Enum Mount Points: http://msdn.microsoft.com/library/en-us/fileio/base/enumerating_mount_points.asp] or GetLogicalDrives()

Last updated on 2007-05-07 04:21:53 -0700, by Shalom Craimer

Back to Tech Journal