Skip to main content

IOCTL_DISK_FLUSH_CACHE

You can use IOCTL_DISK_FLUSH_CACHE to Flash all your data immediately to the Flash Memory.

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.
Send Feedback!