An ERROR_ACCESS_DENIED error is returned in Windows Server 2003, Windows Vista, or Windows Server 2008 when you call the DeviceIoControl function together with the FSCTL_LOCK_VOLUME control code
Consider the following scenario:
- You open or create a file by calling a function and setting the FILE_FLAG_DELETE_ON_CLOSE flag on a computer that is running Windows Server 2003, Windows Vista, or Windows Server 2003.
- You create a file mapping object for the file and then create a mapped view object for the file mapping object.
- You close the file before the mapped view is unmapped.
- You try to lock the volume that stores the file by calling the DeviceIoControl function together with a FSCTL_LOCK_VOLUME control code.
In this scenario, the DeviceIoControl function fails and an ERROR_ACCESS_DENIED error is returned.
This problem affects applications that use the DeviceIoControl function to lock a volume. For example, some backup applications may crash or raise exceptions unexpectedly.
For more information on this issue, including potential causes, workarounds, and resolutions, see: Microsoft KB Article KB974127.