[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

Enumerate File Handles for a Given Process

Demetri

2/7/2007 2:38:00 AM

The short question I have here is how would one enumerate file handles for a
given process in C#?

I know p/invoke is needed. Sysinternals uses NtQuerySystemInformation and
NtQueryObject. However, my knowledge of how to uses these are pretty limited
and to save myself some time of ramping up on them I was wondering if someone
already knew how to do this in C#? Or can point me to some sample code on
doing this would be great.

I have even found some code but it doesn't work correctly. It displays file
handles but only for the executing process (the application the code is
running in, i.e. my project) which is not the desired results.
--
-Demetri
1 Answer

Michael Nemtsev [MVP]

2/7/2007 9:08:00 AM

0

Hello Demetri,

D> know p/invoke is needed. Sysinternals uses NtQuerySystemInformation
D> and NtQueryObject. However, my knowledge of how to uses these are
D> pretty limited and to save myself some time of ramping up on them I
D> was wondering if someone already knew how to do this in C#? Or can
D> point me to some sample code on doing this would be great.

See the sample of using PInvoke there http://quickstart.developerfusion.co.uk/QuickStart/howto/doc/Interop/PInvoke_S...

But your can use WMI for this, because NtQuerySystemInformation should mapped
on Win32_Process class
Look at that way

---
WBR, Michael Nemtsev [C# MVP]. Blog: http://spaces.live.c...
team blog: http://devkids.blo...

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo