C# Determine when an external app is run or exited [duplicate]

此生再无相见时 提交于 2019-12-07 14:47:06

问题


What's the best way, from a long-running process, to detect when the first instance of an arbitrary application (e.g. MS Word) is launched, and when the last instance of it is closed? (Actual process terminated, not just being hidden to taskbar etc)


回答1:


You can use WMI. There are two classes that you might be interested in Win32_ProcessStartTrace Class and Win32_ProcessStopTrace Class. Check this project for more information.




回答2:


You can use Process class

Here is a good solution: C# console app to monitor a process and its CPU



来源:https://stackoverflow.com/questions/6525267/c-sharp-determine-when-an-external-app-is-run-or-exited

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!