在CreateFile()之前需要延迟?

时间:2013-06-26 10:10:59

标签: c winapi file-io delay

我对CreateFile

的使用有一个疑问

我的代码序列如下:

CreateFile to get handle A
.....
Close handle A
GetDiskFreeSpace  // if handle A is not closed, this API fails...
.....         
CreateFile to get handle B  // for File writing Ex. f:\test.dat
WriteFile via handle B      // write file
Close handle B                        
.....
CreateFile to get handle C  // where handle C and A points to the same target !

我的发现是:如果在 "CreateFile to get handle C" 之前没有延迟,那么我收到错误消息“错误:5拒绝访问”

但是如果我在它之前添加1s延迟(例如Sleep(1000))那么一切都还可以,并且句柄C是有效的!

有人能给我一些评论吗?

<平台:VS2008,Win7,测试驱动器是USB闪存笔驱动器

0 个答案:

没有答案
相关问题