知道哪个pid启动了另一个 [英] Know which pid started another one

查看:104
本文介绍了知道哪个pid启动了另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,可以启动其他一些应用程序,它们之间都可以通信.在开发阶段,某些应用程序可能并且确实被挂起,因此您必须手动关闭所有内容.(结束任务,结束任务,结束任务...)到目前为止,开发中的每个人都对每个应用程序都使用了结束任务,现在我必须编写嗅探器知道哪个应用程序启动了哪个应用程序,以关闭具有特定ID的进程.所以问题是:

我怎样才能看到哪个进程开始了?我想要的只是一个PID.我现在只为当前用户获取进程,而没有来自SYSTEM,NETWORK或LOCAL的进程.(我使用dll import方法获取当前进程的用户名,这是迄今为止最快的).这是因为,如果开发人员将主应用程序打开了两次,则我不知道哪个应用程序启动了第二个"过程. 我正在c#中工作.

I have an application that starts some other applications all communicating between them. In developing phase some apps could and do get hanged, so you have to manually close everything.(End Task,End Task,End Task...) So far everyone in developing is using end task for each, and now I have to write a sniffer to know which app was started by which app in order to close the processes with certain id. So the question:

How can I see which process started which ? All i want is a pid. I am now at the point where I get processes only for the current user without the ones from the SYSTEM, NETWORK or LOCAL.(I used the dll import method to get current process username- it''s the fastest so far) I need this because if a developer has the main app opened twice I don''t know which app started the "second" process.
I am working in c#.

推荐答案

看看这个:在答案下,查找24并检查GetParentProcess(IntPtr handle)的代码
http://stackoverflow.com/questions/394816/如何在父级网络中以父方式处理 [
Have a look at this: under answers, look for 24 and check the code for GetParentProcess(IntPtr handle)
http://stackoverflow.com/questions/394816/how-to-get-parent-process-in-net-in-managed-way[^]
The Parent process should be the one you are looking for - with a bit of luck!


这篇关于知道哪个pid启动了另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆