本文介绍了Windows 7在物理驱动器上的WriteFile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一段代码,可以使用WriteFile将扇区写入物理磁盘.在Win XP下可以正常工作,但在Windows 7下(未尝试Vista)不能正常工作.它返回错误代码ERROR_ACCESS_DENIED.阅读 http://msdn.microsoft.com/en-us/library/aa365747%28VS.85%29.aspx [ ^ ]我看到我应该卸下或锁定与物理设备关联的卷.我添加了枚举卷的代码,并使用FSCTL_LOCK_VOLUME调用了DeviceIoControl.现在,当我调用WriteFile时,即使我重复WriteFile调用,也会得到错误代码ERROR_DEVICE_CHANGED.

我该怎么办?

I have a piece of code that writes sectors to a physical disk using WriteFile. This works fine under Win XP, but not under Windows 7 (Not tried Vista). It returns an error code of ERROR_ACCESS_DENIED. Having read http://msdn.microsoft.com/en-us/library/aa365747%28VS.85%29.aspx[^] I can see that I should be dismounting or locking the volumes associated with the physical device. I added code to enumerate the volumes and called DeviceIoControl with FSCTL_LOCK_VOLUME. Now when I call WriteFile I get the error code ERROR_DEVICE_CHANGED, even if I repeat the WriteFile call.

What should I be doing?

推荐答案



这篇关于Windows 7在物理驱动器上的WriteFile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 05:17