如何在 C# 中按进程获取打开的文件句柄列表? [英] How do I get the list of open file handles by process in C#?

查看:34
本文介绍了如何在 C# 中按进程获取打开的文件句柄列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 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.

这很可能需要互操作.

考虑到为此增加赏金,实现起来非常复杂.

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

推荐答案

哎呀,这很难从托管代码中做到.

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

有一个代码项目示例

大部分内容都可以在互操作中完成,但是您需要一个驱动程序来获取文件名,因为它位于内核的地址空间中.Process Explorer 将驱动程序嵌入到其资源中.将这一切从 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.

这篇关于如何在 C# 中按进程获取打开的文件句柄列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆