2013-07-13 45 views

回答

2

您可以使用AntiVirusProduct WMI类,具体取决于您必须连接到root\SecurityCenterroot\SecurityCenter2命名空间的窗口版本。

欲了解更多详情检查本文 Getting the installed Antivirus, AntiSpyware and Firewall software using Delphi and the WMI

注:AntiVirusProduct WMI类只支持Windows桌面版(Windows XP,Windows Vista中,7,8)。

试试这个例子。

function IsAntivirusInstalled: Boolean; 
var 
    FSWbemLocator: Variant; 
    FWMIService : Variant; 
    FWbemObjectSet: Variant; 
    Version: TWindowsVersion; 
begin 
    GetWindowsVersionEx(Version);  
    Result := false; 
    FSWbemLocator := CreateOleObject('WBEMScripting.SWBEMLocator'); 

    if (Version.Major = 5) and (Version.Minor = 1) then //Windows XP 
     FWMIService := FSWbemLocator.ConnectServer('', 'root\SecurityCenter', '', '') 
    else 
    if (Version.Major = 6) then 
     FWMIService := FSWbemLocator.ConnectServer('', 'root\SecurityCenter2', '', '') 
    else 
    exit; 

    FWbemObjectSet := FWMIService.ExecQuery('SELECT displayName FROM AntiVirusProduct'); 
    Result := (FWbemObjectSet.Count > 0); 
    FWbemObjectSet := Unassigned; 
    FWMIService := Unassigned; 
    FSWbemLocator := Unassigned; 
end; 
相关问题