Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / February 2007

Tip: Looking for answers? Try searching our database.

Enumerate File Handles for a Given Process

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Demetri - 07 Feb 2007 02:38 GMT
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.
Signature

-Demetri

Michael Nemtsev - 07 Feb 2007 09:08 GMT
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_Sim
ple.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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.