如何从进程中获取已打开文件的句柄列表 [英] How to get list of handles of opened files from a process

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

问题描述

大家好,
我有一个问题:
如何从进程中获取已打开文件的列表? 如您所知,与该进程相关联的进程的每个窗口,文件或另一个对象都可以由它们操作.每个文件都有一个句柄(这与其他文件是唯一的),我们可以在操作过程中关闭该文件,也可以对该文件执行任何操作.当然,当我们关闭该文件时,可能会发生错误...但是由于某些原因,我们希望由我们的程序来执行此操作(根据程序的工作,但是我们无法做到这一点????
我制作了一个程序,该程序获取在内存中运行的进程的列表.
这是描述如何从内存中获取进程列表的代码:

Hi every one,
I have a questio:
how to get list of opened files from a process????!!!!!
As you know, each window,file or another object associated to a process that the process can operate by them. And each of these files have a handle (that is unique from other files) and we can close that file while porcess operating or we can do any operation on that file. Ofcourse, when we close that file might an error happened... but we want to do it by our program for some reason (accourding to the job of the program, but how we cant do it?????
I have made a program that get the list of processes operating in the memory.
and this is the code that descripe how to get list of processes from the memory:

For Each P As Process In Process.GetProcesses()
            MsgBox(P)
        Next



现在,如何通过这些过程之一获取打开文件的句柄??????

希望您有答案...



Now, how to get the handles of opened files by one of these proceses??????

I hope you have answer......

推荐答案

我不知道在托管环境中这有多么容易(我从未尝试过),但是在那里是这里的文章可能会有所帮助:
I have no idea how easy this is in a Managed environment (I''ve never tried) but there is an article here that may help: Listing Used Files[^]

It''s VC6 which means it''s native code C++, but you may be able to use it. If nothing else, you can use Interop to call the routines from your code.


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

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