Determining Parent Process ID from C #

I would like to determine the process ID of the parent process for an arbitrary process on Windows.

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

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

I am a bit worried about using the apis dashboard because they are 32 bit in nature.

Additional Information:

The solution of the performance counter in the FAQ is : (PerformanceCounter ("Process", "Creating a process identifier", procName);) scares me because it does not allow you to enter a process identifier, instead you specify a process by name so that all this can become rude form when you have several children.

+3
source share
2 answers

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

+2
source

Use NAPI (Win32 Frequently Asked Questions)

-1
source

Source: https://habr.com/ru/post/1706864/


All Articles