You need to use WMI, the Win32_Process class includes the parent process id. So a WQL query (see System.Management namespace for WMI under .NET) like:
SELECT * FROM Win32_Process Where ParentProcessId = n
replacing n with the service's process id.
EDIT Sample code (based on code by Arsen Zahray):
static List<Process> GetChildProcesses(int parentId) {
var query = "Select * From Win32_Process Where ParentProcessId = "
+ parentId;
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
ManagementObjectCollection processList = searcher.Get();
var result = processList.Cast<ManagementObject>().Select(p =>
Process.GetProcessById(Convert.ToInt32(p.GetPropertyValue("ProcessId")));
).ToList();
return result;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…