我如何在C#中打开文件的列表处理由过程?过程、文件、如何在、列表

2023-09-02 01:17:59 作者:孤单一个人

我如何在C#中打开文件的列表处理由进程id?

How do I get the list of open file handles by process id in C#?

我感兴趣的挖下去,并得到该文件的名称为好。

I'm interested in digging down and getting the file names as well.

寻找什么工艺资源管理器的方案相同。

Looking for the programmatic equivalent of what process explorer does.

这很可能将需要互操作。

Most likely this will require interop.

考虑在这个加赏金,实现是讨厌复杂。

Considering adding a bounty on this, the implementation is nasty complicated.

推荐答案

哎哟这将是很难从管理code做。

Ouch this is going to be hard to do from managed code.

有一个sample在$ C $的CProject

大部分的东西可以互操作来完成,但你需要一个驱动程序来获取文件名,因为它生活在内核的地址空间。进程管理器嵌入在其资源的驱动程序。入门这一切都从C#和支持64位及32挂接,将是一大难题。

Most of the stuff can be done in interop, but you need a driver to get the filename cause it lives in the kernel's address space. Process explorer embeds the driver in its resources. Getting this all hooked up from C# and supporting 64bit as well as 32, is going to be a major headache.