我用WMI的时候,就是想不到如何获取这个···怎么弄都无法实现···想了挺久了···也就看见一个VBS的代码,如下strComputer ="."Set Security = Getobject("winmgmts:\\" & strComputer & "\root\SecurityCenter")
Set Viruses = Security.InstancesOf("AntiVirusProduct")
For Each Virus In Viruses
msgbox Virus.displayName
next
好像要在\root\SecurityCenter下获取AntiVirusProduct的值吧
但是就是弄不到····
还希望大家指点一二,谢谢···我实验很多了··一个都没成···

解决方案 »

  1.   

    试试看这个            string computer = Environment.MachineName;   
                //string wmipath = "winmgmts:{impersonationLevel=impersonate}!\\" + computer + "\\root\\SecurityCenter";  
                string wmipath = @"\\" + computer + @"\root\SecurityCenter";  
                string antivirusProduct = string.Empty;
                ManagementObjectSearcher search = new ManagementObjectSearcher(wmipath + "SELECT * FROM AntivirusProduct");   
                foreach (ManagementObject o in search.Get())   
                {   
                    antivirusProduct = o["displayName"].ToString();    
                }   
    return antivirusProduct;
      

  2.   

    更正一个错误    string computer = Environment.MachineName;   
        //string wmipath = "winmgmts:{impersonationLevel=impersonate}!\\" + computer + "\\root\\SecurityCenter";  
        string wmipath = @"\\" + computer + @"\root\SecurityCenter";  
        string antivirusProduct = string.Empty;
        ManagementObjectSearcher search = new ManagementObjectSearcher(wmipath,"SELECT * FROM AntivirusProduct");   
        foreach (ManagementObject o in search.Get())   
        {   
          antivirusProduct = o["displayName"].ToString();    
        }   
        return antivirusProduct;
      

  3.   


    ManagementObjectSearcher 需要引用什么?
      

  4.   

    ManagementObjectSearcher 需要引用System.Management;
      但是有异常跑出.
    search.get()  Invalid namespace.
      

  5.   


    From MSDN:Hi Subash, For your concern how the windows security center recognizes various antivirus softwares installed on your PC, try to refer to the following explanations:Windows Security Center uses a two-tiered approach for detection status. One tier is manual, and the other tier is automatic through Windows Management Instrumentation (WMI). In manual detection mode, Windows Security Center searches for registry keys and files that are provided to Microsoft by independent software manufacturers. These registry keys and files let Windows Security Center detect the status of independent software. In WMI mode, software manufacturers determine their own product status and report that status back to Windows Security Center through a WMI provider. In both modes, Windows Security Center tries to determine whether the following is true: • An antivirus program is present.  
    • The antivirus signatures are up-to-date.  
    • Real-time scanning or on-access scanning is turned on for antivirus programs.  
    • For firewalls, Windows Security Center detects whether a third-party firewall is installed and whether the firewall is turned on or not. 
     As far as I know, there is no general solution for this. Typically, the developers know the names of antiviruses. So most of the solutions are based on:
    1). Identifiying the AV by product name (you can get the list of installed software via Win32_Product or as it was suggested, by installer api). Try to check out this document about Win32_Product class for details - http://msdn2.microsoft.com/en-us/library/aa394378(VS.85).aspx
    2). Identifiying the AV by service names Hope this helps,Regards,
      

  6.   

    Invalid Query是你的杀毒软件非M$认证的, 比较老的杀毒的.
    到M$网站下一个WMI Tools, 查看一下有没有root\SecurityCenter就可以知道了.
    http://www.microsoft.com/downloads/details.aspx?familyid=6430F853-1120-48DB-8CC5-F2ABDC3ED314&displaylang=en
      

  7.   

    没有,其实是wmipath + "SELECT * FROM AntivirusProduct"
    如果用这样传递的参数,就有那个问题了
    系统自带好像就有WMI的测试工具,我用过,挺厉害···