如何检查后台运行的Microsoft Security Essential?

时间:2014-10-20 12:14:47

标签: c#

我正在创建一个检测系统威胁的软件,但它需要Microsoft Security Essentials来清理该系统。因此,我想知道Microsoft Security Essentials是否在系统上运行,因此我可以使用此实用程序来使我的软件正常运行。我已经有了这个解决方案来检查是否安装了Microsoft Security Essentials,但我需要知道它是否正在运行?提前谢谢。

要检查Microsoft安全性,我已实现以下代码

private static bool DoesMseExist()
    {
        string location = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
        using (RegistryKey localMachineX64View =
                     RegistryKey.OpenBaseKey(RegistryHive.LocalMachine,
                     RegistryView.Registry64))
        {
            using (RegistryKey rk = localMachineX64View.OpenSubKey(location))
            {
                foreach (string subKey in rk.GetSubKeyNames())
                {
                    using (RegistryKey productKey = rk.OpenSubKey(subKey))
                    {
                        if (productKey != null)
                        {
                            if (Convert.ToString(productKey.GetValue("DisplayName"))
                               .Contains("Microsoft Security Client"))
                            {
                                return true;
                            }
                        }
                    }
                }
            }
        }
        return false;
    }

1 个答案:

答案 0 :(得分:0)

我终于得到了答案,它对我有用。

Process[] processlist = Process.GetProcessesByName("msseces");;
foreach(Process theprocess in processlist){
   Console.WriteLine("Process: {0} ID: {1}", theprocess.ProcessName, theprocess.Id);
}