Search by Tags

IOCTL_DISK_FLUSH_CACHE

 
Applicable for

Compare with Revision
Subscribe for this article updates

You can use IOCTL_DISK_FLUSH_CACHE to Flash all your data immediately to the FlashMemory. You need to set lpInBuffer = -1 to use the function!

Define

//diskio.h not in SDK, so we have to add this
#define IOCTL_DISK_BASE FILE_DEVICE_DISK
#define IOCTL_DISK_FLUSH_CACHE \
    CTL_CODE(IOCTL_DISK_BASE, 0x715, METHOD_BUFFERED, FILE_ANY_ACCESS)

Sample

DWORD forceFlush=-1;
HANDLE hStore = INVALID_HANDLE_VALUE;
DWORD res=0;
 
hStore = OpenStore(L"DSK1:");
DeviceIoControl(hStore, IOCTL_DISK_FLUSH_CACHE, &forceFlush, sizeof(forceFlush), &res, sizeof(res), NULL, NULL);
CloseHandle(hStore);

Known Issues

  • The function always returns 0, even when the call was successful.