tags:

views:

1181

answers:

3

I would like to determine the process id of the parent process for an arbitrary process in Windows.

I need this method to work on both x64 and x32.

Any ideas / sample code to make this happen. System.Diagnositics.Process does not include this info.

I am a bit worried about using the toolhelp apis cause they are 32 bit specific.

Related info:

The Performance counter solution in the FAQ: (PerformanceCounter("Process", "Creating Process ID", procName);) scares me, cause it does not allow you to enter a process id, instead you specify a process by name so it all can go pear shape when you have multiple children.

+2  A: 

WIN32_Process has processid and parent processid. Getting the WMI data on 64-bit is a bit more difficult, but still possible by changing the provider flags.

JP Alioto
yeah System.Management is a much easier path to take
Sam Saffron
A: 

Use NAPI (Win32 FAQ)

A: 

This question has a code example in it.

romkyns