2013-07-13 149 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; 
相關問題