I need to discover what file handles a process has open. The best example is what system internals ProcessExplorer does. However they use NtQuerySystemInformation which it a C call.
While I'm not against wrapping the call I figure there must be a direct C# call. The closest c# option I can find is WMI calls. Win32Process will tell me what processes I'm running but it won't tell me what file handles I have open.
Get started with Basic Manufacturing and experience how MISys Manufacturing software delivers on its promise to turn your QuickBooks accounting software into an industrial-strength manufacturing system. Here are the top 10 reasons why manufacturers add MISys Manufacturing software: Track inventory in work-in-process (WIP).
Question: 1) Is there a WMI call that can tell me what File Handles are open? Either for a given process or at least what PID is holding the file handle? 2) Is there any other call I can do to copmlete this task? Hello NtQuerySystemInformation is not recommended to use in applications, so I do not suggest it even though you may be able to P/Invoke the API from C#.
I'm not aware of a WMI class that can tell what file handles are open. May I know the business requirement behind the request of enumerating open file handles for a process? If you want to find out who has a file open, you may propably try the restart manager API which is available in Windows Vista and later operating systems. The primary reason software installation and updates require a system restart is that some of the files that are being updated are currently being used by a running application or service. Restart Manager enables all but the critical applications and services to be shut down and restarted. This frees the files that are in use and allows installation operations to complete. It can also eliminate or reduce the number of system restarts that are required to complete an installation or update.
Another idea is to redirect stdIO of handle.exe utility and parseĀ its output to get the opened files of a process. However, third party applications are not allowed to distribute the tool: Q: May I distribute Sysinternals utilities in my software, on my website, or with my magazine?
We are not offering any distribution licenses, even if the 3rd party is distributing them for free. We encourage people to download the utilities from our download center where they can be assured to get the most recent version of the utility. Regards, Jialiang GePlease remember to mark the replies as answers if they help and unmark them if they provide no help. If you have any feedback, please tell us. Hi Jialiang and Mark,I met the similar problem in Hyper-V on Windows 2012 Server.
The Virtual Machine might became zombie if I made a mistake on manipulate it. The VM did not show on hyper-V manager. Its process 'vmwp' show in 'Task Manager'. I killed the vmwp.
But somefiles registered in Hyper-V were still hold by vmms, the service of 'Hyper-V Virtual Machine Management'. Those files were shown in 'Process Explorer - Sysinternals' program.Is it possible to close those files' handler without restart/stop vmms service programmatically? My program is written in C#.
How can I find the file handler by given full file name?Regards,Guangjie.