Kumar Puran

I want to lock a volume using FSCTL_LOCK_VOLUME. This is working fine until there is no file open from that volume.

How can i lock the volume, even if soem files are open

Kumar



Re: Visual C++ General FSCTL_LOCK_VOLUME

Prasad Somwanshi

How can i lock the volume, even if soem files are open

No , You can't.

Refer remark section of MSDN for it. Following lines are from it only,

This operation fails if there are any open files on the volume. Conversely, success of this operation indicates there are no open files.





Re: Visual C++ General FSCTL_LOCK_VOLUME

Kumar Puran

I know it.. but the error thrown is "Access Denied", if files are open.

So, there might be some access rights permissions getting which, we can Lock the volume even if files are open.

On the other hand, is there any way to Close those open files, before trying for lock

Kumar





Re: Visual C++ General FSCTL_LOCK_VOLUME

Prasad Somwanshi

but the error thrown is "Access Denied", if files are open

yes, as file is opened by other process, thats why access is denied.

On the other hand, is there any way to Close those open files, before trying for lock

Its should be done by process opened it, as it will have handle to close the file.





Re: Visual C++ General FSCTL_LOCK_VOLUME

Kumar Puran

file is opened by other process, thats why access is denied

Okk...i already know it...my main concern is: there might be some access rights permissions getting which, we can Lock the volume even if files are open.

Its should be done by process opened it, as it will have handle to close the file.

That's what i want to purposely find out all those process and kill those before locking the Volume. Did u get me





Re: Visual C++ General FSCTL_LOCK_VOLUME

Shakje

Access denied does not mean that there is a problem with permissions, it purely means that something is stopping you from accessing the file or disk. This could be down to permissions, but in this case it is not.




Re: Visual C++ General FSCTL_LOCK_VOLUME

Damien Watkins - MSFT

Hello

Re question:

Such questions are outside the scope of this forum - for the scope of the VC General forum please look at: http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=19445&SiteID=1

The more appropriate place for your question is probably one of the Win32 newsgroups: http://msdn.microsoft.com/newsgroups/topic.aspx url=/MSDN-FILES/028/201/015/topic.xml

OTP

Thanks

Damien