gpt4 book ai didi

c# - 如何以编程方式获取已安装的防病毒软件和防火墙?

转载 作者:太空狗 更新时间:2023-10-29 23:22:56 25 4
gpt4 key购买 nike

如何获取有关安装在 Windows 计算机上的防病毒软件和防火墙软件的信息?

最佳答案

您可以使用 ManagementObjectSearcher 获取此信息。

 Public Function GetAntivirus() As String
Try
Dim data As String = String.Empty
For Each firewall As ManagementObject In New ManagementObjectSearcher("root\SecurityCenter" & IIf(My.Computer.Info.OSFullName.Contains("XP"), "", "2").ToString, "SELECT * FROM AntiVirusProduct").Get
data &= firewall("displayName").ToString
Next
If Not data = String.Empty Then
Return data
Else
Return "No Antivirus"
End If

Catch
Return "No Antivirus"
End Try

End Function

Public Function GetFirewall() As String
Try

Dim data As String = String.Empty
For Each firewall As ManagementObject In New ManagementObjectSearcher("root\SecurityCenter" & IIf(My.Computer.Info.OSFullName.Contains("XP"), "", "2").ToString, "SELECT * FROM FirewallProduct").Get
Data &= firewall("displayName").ToString
Next
If Not data = String.Empty Then
Return data
Else
Return "No Firewall"
End If
Catch
Return "No Firewall"
End Try

End Function

关于c# - 如何以编程方式获取已安装的防病毒软件和防火墙?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22153879/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com