Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get PIDs that are using given file name in C#?

How to get PIDs of processes that are using a given file name and mutex name? (Not by custom kernel driver, but in C# in user mode.)

UPDATE: Thanks to Daniel Renshaw I found a script that lists all handles with PIDs. (Using a not undocumented and unfrozen functions.)

like image 988
TN. Avatar asked Jun 10 '10 09:06

TN.


1 Answers

The following two SO questions may be of use:

How do I find out which process is locking a file using .NET?

Summary: use handle.exe and parse the output (i.e. not a great solution)

Win32: How to get the process/thread that owns a mutex?

Summary: may not be possible in user mode without using deprecated or undocumented functions (but some smaple code is provided in this question).

like image 61
Daniel Renshaw Avatar answered Oct 09 '22 11:10

Daniel Renshaw