问题
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