在.NET中是否有一个事件来获取Windows进程列表? [英] Is there an event in .NET to get a list of windows processes ?

查看:96
本文介绍了在.NET中是否有一个事件来获取Windows进程列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以编程方式监视和记录计算机中运行的进程的活动。每次进程开始和结束时,我们如何获得在Windows中运行的进程列表?在流程开始或结束时是否会触发.NET中的事件?

任何帮助都将非常感激。



我尝试过:



我找不到合适的课程来完成流程管理。

I want to programatically monitor and log the activity of processes running in a computer. How can we get a list of processes running in windows each time a process starts and ends? Is there an event in .NET that is triggered when a process starts or ends?
Any help will be very appreciated.

What I have tried:

I didn't find a proper class to complete managing of processes.

推荐答案

您需要使用WMI,并订阅 Win32_ProcessStartTrace [ ^ ]和 Win32_ProcessStopTrace [ ^ ]事件,或较低级别的 __InstanceCreationEvent [ ^ ]和 __ InstanceDeletionEvent [ ^ ]活动。



中有一个例子这个StackOverflow回答 [ ^ ]监控进程具体名称。
You'll need to use WMI, and subscribe to the Win32_ProcessStartTrace[^] and Win32_ProcessStopTrace[^] events, or the lower-level __InstanceCreationEvent[^] and __InstanceDeletionEvent[^] events.

There's an example in this StackOverflow answer[^] which monitors processes with a specific name.


这篇关于在.NET中是否有一个事件来获取Windows进程列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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