flushes(cvi中writefile函数怎么使用)
资讯
2023-11-13
273
1. flushes,cvi中writefile函数怎么使用?
writefile函数通常是将数据写入到内部缓冲区,然后OS会定期将缓冲区中的数据写入到磁盘。如果想在调用WriteFile之后,数据就立即写入磁盘,有如下三种方法:
1.调用FlushFileBuffers(hFile);Flushesthebuffersofaspecifiedfileandcausesallbuffereddatatobewrittentoafile.BOOLFlushFileBuffers(HANDLEhFile//openhandletofilewhosebuffersaretobeflushed);该函数会将指定文件的缓存数据写入磁盘。
2.在用CreateFile创建文件的时候,第6个参数使用标志FILE_FLAG_WRITE_THROUGHInstructstheoperatingsystemtowritethroughanyintermediatecacheandgodirectlytodisk.Theoperatingsystemcanstillcachewriteoperations,butcannotlazilyflushthem.
3.关闭掉句柄CloseHandle(hFile);
本站涵盖的内容、图片、视频等数据系网络收集,部分未能与原作者取得联系。若涉及版权问题,请联系我们删除!联系邮箱:ynstorm@foxmail.com 谢谢支持!
1. flushes,cvi中writefile函数怎么使用?
writefile函数通常是将数据写入到内部缓冲区,然后OS会定期将缓冲区中的数据写入到磁盘。如果想在调用WriteFile之后,数据就立即写入磁盘,有如下三种方法:
1.调用FlushFileBuffers(hFile);Flushesthebuffersofaspecifiedfileandcausesallbuffereddatatobewrittentoafile.BOOLFlushFileBuffers(HANDLEhFile//openhandletofilewhosebuffersaretobeflushed);该函数会将指定文件的缓存数据写入磁盘。
2.在用CreateFile创建文件的时候,第6个参数使用标志FILE_FLAG_WRITE_THROUGHInstructstheoperatingsystemtowritethroughanyintermediatecacheandgodirectlytodisk.Theoperatingsystemcanstillcachewriteoperations,butcannotlazilyflushthem.
3.关闭掉句柄CloseHandle(hFile);
本站涵盖的内容、图片、视频等数据系网络收集,部分未能与原作者取得联系。若涉及版权问题,请联系我们删除!联系邮箱:ynstorm@foxmail.com 谢谢支持!