且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在没有得到 ERROR_ACCESS_DENIED 的情况下将文件写入 PhysicalDrive (Windows 7)?

更新时间:2022-11-03 20:11:55

我没有遇到不同 WriteFile() 大小的问题,但我确实解决了

I didn't have problems with different WriteFile() sizes, but I did solve the

WriteFile(): 访问被拒绝'.physicaldriveX

WriteFile(): Access is denied <ERROR_ACCESS_DENIED/5> to '.physicaldriveX

在 Windows 7 中以管理员身份运行的设备(通常是 USB HDD/SSD)(提升权限)如下:

devices (usually USB HDD/SSD) in Windows 7 running as Administrator (elevated rights) as follows:

计算机管理 -> 磁盘管理:

Computer Management -> Disk Management:

  • 卷(H:在你的情况下)->右键单击->删除卷
  • 磁盘(在您的情况下为磁盘 2)-> 右键单击​​ -> 离线
  • 磁盘(在您的情况下为磁盘 2)-> 右键单击​​ -> 在线

之后,我可以毫无问题地写入.physicaldriveX".

After that, I'm able to write to '.physicaldriveX' with no problem.

我认为只要设备上有任何文件系统,Win7 就会锁定(与以前的 Windows 版本不同)物理设备以避免一致性问题.

I think the Win7 locks (unlike previous Windows releases) the physical device as long as there is any file system on the device to avoid consistency problems.