Windows Service C#获取进程列表

时间:2018-06-05 20:59:04

标签: c# windows process windows-services

我在c#中编写一个简单的Windows服务。 我想在我的计算机上获取进程列表,并且" kill"我用windows窗口制作的另一个程序。特别是当它达到300MB的内存消耗时,我想杀掉那个程序。

        Process[] processlist = Process.GetProcesses();

        foreach (Process theprocess in processlist)
        {
            String path = @"C:\\tmp\\" + theprocess.ProcessName;
            File.Create(path);
        }

使用此代码我只获得3个进程:conhost,devenv,svchost。 我想获得我可以通过任务管理器看到的所有进程列表。 有人可以帮帮我吗? 感谢您的任何建议

0 个答案:

没有答案