Quantcast
Viewing all articles
Browse latest Browse all 168

Questions about file handles and locking

What API function can be used to determine what file handles already exist for a file, being accessed by another program?

I know that if there's a file you want to delete and another program has not released its lock on it, you can use software called Unlocker or another one called Lock Hunter, and what it does it does is show you what programs currently have a file locked, and allow you to forcibly unlock it. This is very useful if another program had opened a file but failed to close it properly (bug in the program), and now you want to delete the file, but don't want to have to close down the program associated with the lock on that file.

But my question is, what API calls are such programs as Unlocker actually using? Usually the way you lock or unlock a file is to use CreateFile to open it, which gives you a file handle. You then use that file handle with the LockFile and UnlockFile API calls to lock and unlock the file. But these 2 API calls assume you have access to the file handle to start with. If I'm trying to unlock a file locked by another program however, I do not have access to that particular handle. Is there some API call that allows you to get the file handle associated with another program's accessing of a particular file? If not, how do programs like Unlocker and Lock Hunter actually unlock all the locks associated with a particular file?

Viewing all articles
Browse latest Browse all 168

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>