You can use IOCTL_DISK_FLUSH_CACHE to Flash all your data immediately to the Flash Memory.
//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)
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);