我需要一种更好的方法来查询安装的防病毒软件.也许在C#中这样的东西



是否有c#等同于此?我尝试使用WMI,并且只需获得" Windows Defender",而不管安装了WMI符合WMI的防病毒软件。

我只想在文本框中显示这些结果。

WMIC /Node:localhost /Namespace:\rootSecurityCenter2 Path AntiVirusProduct         Get displayName /Format:List 

当我使用上面的代码时,我会得到防病毒的实际名称。

您可以向System.Management添加引用。然后使用ManagementObjectSearcher您可以运行WMI查询。

要查找应在SecurityCenter2中搜索的安装防病毒。例如:

var path = string.Format(@"\{0}rootSecurityCenter2", Environment.MachineName);
var searcher = new ManagementObjectSearcher(path, "SELECT * FROM AntivirusProduct");
var instances = searcher.Get().Cast<ManagementObject>()
                        .Select(x => (string)x.GetPropertyValue("displayName"))
                        .ToList();

注1:对于Windows XP,在SecurityCenter中搜索。

注2:您也可以读取AntiVirusProduct的其他属性:

  • displayNamestring
  • instanceGuidstring
  • pathToSignedProductExestring
  • pathToSignedReportingExestring
  • productStateUInt32。(有关如何解析状态的信息,请查看此帖子。)
  • timestampstring

最新更新