【问题标题】:Inno Setup Check if Antivirus Software is InstalledInno Setup 检查是否安装了杀毒软件
【发布时间】:2013-07-13 09:38:29
【问题描述】:

有没有办法检查是否使用 Inno Setup 安装了杀毒软件?

【问题讨论】:

  • 您要检查特定的防病毒软件还是任何防病毒软件?

标签: inno-setup antivirus


【解决方案1】:

您可以使用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;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-10-22
    • 1970-01-01
    • 1970-01-01
    • 2011-05-05
    • 1970-01-01
    • 2022-01-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多