|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Enumerate File Handles for a Given ProcessThe 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 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_Simple.aspx 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.com/laflour team blog: http://devkids.blogspot.com/ "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 |
|||||||||||||||||||||||