I have been trying to figure out how to programmatically identify the process that has a lock on a particular file. I've searched through the Win32 API and WMI, but so far I can't find anything. I know it's possible - Sysinternals is able to list every resource accessed/locked by every process on the system.
Can anyone drop me a hint?
WhoLockMe is a nice right click windows explorer extension.
Please look at http://windowsxp.mvps.org/processlock.htm
I don't know in Windows, but somebody might find useful to know that, in Linux, you can use the lsof command, or just search through the folders /proc/PROCESS_ID/fd and see what process has opened the file.
You can use handle.exe from Sysinternals.
Something like:
Thanks to https://stackoverflow.com/a/599268/367916 .
You could use Process Explorer from Microsoft
This article might be helpful to you.
It appears you are forced to search through the list of files for each process on the system using undocumented functions in ntdll.dll.