2

Using MS Windows, deleting a file sometimes does not work since "file xyz.abc is used by another process" message appears. Sometimes the message tells me which process is holding the handle, mostly it does not.

So I'm wondering if it is possible to get all PIDs/Handles that are "locking" this file I want to delete.

I already found a WinAPI function that tells me the process name of a handle. What I need is a function, that tells me the PIDs/Handles assigned to a file.

It would be glad if you could provide some code (in C/C++ or any .NET language)

Thanks in advance!

Radinator
  • 1,048
  • 18
  • 58
  • 2
    Yes you can but stack overflow doesnt give you code.. it helps you fix your code. Do a google - thats where I got mine from - such as http://stackoverflow.com/questions/3899864/what-process-locks-a-file/3900019 – BugFinder Feb 20 '17 at 13:34
  • The [Restart Manager](https://msdn.microsoft.com/library/cc948910.aspx) provides this functionality. See [How do I find out which process has a file open?](https://blogs.msdn.microsoft.com/oldnewthing/20120217-00/?p=8283) for complete code sample. – IInspectable Feb 20 '17 at 13:49
  • @IInspectable thank you for your advise, i read to quickly the orinigal post and understood the threadstarter than he already gets the process-name which is currently locking given file. Now i see that i was wrong. – Alexander Powolozki Feb 20 '17 at 14:58

0 Answers0