4

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.

Sam Saffron
  • 128,308
  • 78
  • 326
  • 506
  • 1
    [This question](http://stackoverflow.com/questions/394816/how-to-get-parent-process-in-net-in-managed-way) has a code example in it. – Roman Starkov Nov 28 '09 at 18:12

2 Answers2

2

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
  • 44,864
  • 6
  • 88
  • 112
-1

Use NAPI (Win32 FAQ)