processes in xp

  • Thread starter Thread starter cs
  • Start date Start date
C

cs

is there an easy way to walk the process tree of winxp on .net? I dont mean
the regular stuff u can do on the process class, but things like end process
tree, or finding who is the parent of a process, etc. I am guessing its
easily doable calling system dlls?
 
There is no concept of a Parent Process in Windows. At least, it's not
exposed. Certain programs like ProcessExp in SysInternals.com achieve this
by using Undocumented APIs - which is not recommended.

-vJ
 
Don't know where you get this from, but both statements are incorrect.
1)The Win32 API's CreateProcess, CreateProcessAsUser etc. do create Child
processes and as such the calling process is the parent of the child
process, right? (Just search MSDN for "parent process")
2) The Kernel32.dll API CreateToolhelp32Snapshot, can be used to take a
snapshot of all processes in the system, and
Process32First, Process32Next etc. can be used to walk the process chain,
they return a structure PROCESSENTRY32 that contains, amongst others, the
parentProcessId. And these API's are documented and exposed through the
toolhelp library, just take a look in the Platform SDK (MSDN).

Another [documented] way to walk the process hierarchy is to use
System.Management and the "win32_process class" WMI class.

Note: Sysinternals ProcessExp uses the toolhelp library function to walk the
process trees.

Willy.
 
Yes, using System.Management and the WMI class Win32_Process, else you have
to PInvoke the Toolhelp API's.

Willy.
 
Back
Top