WriteFileå½æ°é常æ¯å°æ°æ®åå
¥å°å
é¨ç¼å²åºï¼ç¶åOSä¼å®æå°ç¼å²åºä¸çæ°æ®åå
¥å°ç£çãå¦ææ³å¨è°ç¨WriteFileä¹åï¼æ°æ®å°±ç«å³åå
¥ç£çï¼æå¦ä¸ä¸ç§æ¹æ³ï¼
1. è°ç¨FlushFileBuffers(hFile);
Flushes the buffers of a specified file and causes all buffered data to be written to a file.
BOOL FlushFileBuffers(
HANDLE hFile // open handle to file whose buffers are to be flushed
);
该å½æ°ä¼å°æå®æ件çç¼åæ°æ®åå
¥ç£çã
2. å¨ç¨CreateFileå建æ件çæ¶å,第6个åæ°ä½¿ç¨æ å¿
FILE_FLAG_WRITE_THROUGH
Instructs
the operating system to write through any intermediate cache and go
directly to disk. The operating system can still cache write operations,
but cannot lazily flush them.
3. å
³éæå¥æ
CloseHandle(hFile);
温馨提示:答案为网友推荐,仅供参考