如何判断系统装过杀软?

解决方案 »

  1.   

    应该有个API吧,WIN都自带了一个这个功能的
      

  2.   

    应该有的以,windows就能自己检测到,它能检测就说明有这功能,,再说了,所有杀毒软件在安装时,也会判断系统以前有没有装过杀软,如有装过,也会给出提示
      

  3.   

    释放一个小病毒,并侦测是否被KILL
      

  4.   

    系统的“安全中心”能做到,所以我们也当然能做到,可以通过WMI来查。root\SecurityCenter  // WMI中“安全中心”的路径
    AntiVirusProduct  // 杀毒软件的相关信息在这个表中
    FirewallProduct  // 防火墙软件的相关信息在这个表中
      

  5.   

    strComputer = "."  
    Set objComputer = CreateObject("Shell.LocalMachine")   
    Set oWMI = GetObject("winmgmts:\\" & strComputer & "\root\SecurityCenter")   
    Set colAV = oWMI.ExecQuery("Select * from AntiVirusProduct")   
      For Each objAntiVirusProduct In colAV   
       If IsNull(objAntiVirusProduct.instanceGuid) Then  
        strSubject = "Anti-virus is not running on " & objComputer.MachineName   
        strTextbody = "You will need to check on " & objComputer.MachineName    
        Call SmtpServer     
       Else  
        strCompany = objAntiVirusProduct.companyName   
        strAV = objAntiVirusProduct.displayName   
        strScanning = objAntiVirusProduct.onAccessScanningEnabled   
        strUptodate = objAntiVirusProduct.productUptoDate  
    这是VC的代码,来个高人把它转换成DELPHI语言啊
    var
      sr: OLEVAriant;
      DE: VAriant;
    begin
      ScriptControl1.Language := 'VBScript';
      sr := ScriptControl1.Eval('getobject("winmgmts:\\.\root\SecurityCenter")');
      DE:=sr.ExecQuery('"Select * From antivirusProduct",48');我这里写到一半写不下去了,来个高人帮帮忙啊?
      

  6.   

    查询到的是一个链表,要去遍历它,像下面这样做。需要先导入WMI Object Viewer Control类库,生成WbemScripting_TLB.pas单元,网上也有,你直接去找一个也行。
    var
      WMILocator: TSWbemLocator;
      WMIServices: ISWbemServices;
      WMIObjectSet: ISWbemObjectSet;
      WMIObject: ISWbemObject;
      WMIProperty: ISWbemProperty;
      Enumerator: IEnumVariant;
      EnumItems: OleVariant;
      EnumItemCount: DWORD;
    begin
      // 创建 WMI 接口
      WMILocator := TSWbemLocator.Create(Self);
      if not Assigned(WMILocator) then Exit;  try
        // 连接 SecurityCenter 数据
        WMIServices := WMILocator.ConnectServer('', 'root\SecurityCenter', '', '', '', '', 0, nil);
        if not Assigned(WMIServices) then Exit;    // 查询杀毒软件 AntiVirusProduct
        WMIObjectSet := WMIServices.ExecQuery('SELECT * FROM AntiVirusProduct', 'WQL', wbemFlagReturnImmediately, nil);
        if not Assigned(WMIObjectSet) then Exit;    // 遍历读取结果
        Enumerator := (WMIObjectSet._NewEnum) as IEnumVariant;
        while (Enumerator.Next(1, EnumItems, EnumItemCount) = S_OK) do
        begin
          WMIObject := IUnknown(EnumItems) as ISWBemObject;
          if not Assigned(WMIObject) then Continue;      // GUID
          WMIProperty := WMIObject.Properties_.Item('instanceGuid', 0);
          OutputDebugString(PChar(string(WMIProperty.Get_Value)));      // 显示名
          WMIProperty := WMIObject.Properties_.Item('displayName', 0);
          OutputDebugString(PChar(string(WMIProperty.Get_Value)));      // 公司名
          WMIProperty := WMIObject.Properties_.Item('companyName', 0);
          OutputDebugString(PChar(string(WMIProperty.Get_Value)));      // 版本号
          WMIProperty := WMIObject.Properties_.Item('versionNumber', 0);
          OutputDebugString(PChar(string(WMIProperty.Get_Value)));      // 是否启用
          WMIProperty := WMIObject.Properties_.Item('onAccessScanningEnabled', 0);
          OutputDebugString(PChar(BoolToStr(Boolean(WMIProperty.Get_Value), True)));      // 是否版本过期
          WMIProperty := WMIObject.Properties_.Item('productUptoDate', 0);
          OutputDebugString(PChar(BoolToStr(Boolean(WMIProperty.Get_Value), True)));
        end;
      finally
        // 释放 WMI 接口
        WMILocator.Free;
      end;
    end;
      

  7.   

    PS:你上面参考的那段代码,可不是VC,是VB哦!
      

  8.   

    function GetAntiVirus:Boolean;
    var
      Wmi, Objs, Obj: OleVariant;
      Enum: IEnumVariant;
      C: Cardinal;
    begin
      Result:=False;
      Wmi := CreateOleObject('WbemScripting.SWbemLocator');
      Objs := Wmi.ConnectServer('.','root\SecurityCenter').ExecQuery('Select * From antivirusProduct');
      Enum := IEnumVariant(IUnknown(Objs._NewEnum));
      Enum.Reset;
      Enum.Next(1, Obj, C);
      if C=1 then
      begin
        Memo1.Lines.Add('杀软名称:'+Obj);
        Result:=True;
      end;end;自己搞定