Unter Umständen benötigen Sie in Ihrer Applikation Informationen über den installierten Virenscanner und dessen Verhalten (Online Scan ...)
Die nachfolgende Funktion lieferte diese Infos (Voraussetzung: Win XP min, SP2).
Das nachfolgende Beispiel benötigt:
Ein Listview Steuerelement (View: Deteils) mit 2 Spalten, 1 Button
Public Function LocalWin32_AVP(ByVal strComputer As String) As String
Dim options As ConnectionOptions
options = New ConnectionOptions()
Dim scope As ManagementScope
scope = New ManagementScope( _
"\\" & strComputer & "\root\SecurityCenter")
scope.Connect()
Dim query As ObjectQuery
query = New ObjectQuery( _
"SELECT * from AntiVirusProduct")
Dim searcher As ManagementObjectSearcher
searcher = New ManagementObjectSearcher(scope, query)
Dim queryCollection As ManagementObjectCollection
queryCollection = searcher.Get()
Dim m As ManagementObject
Dim str As String = String.Empty
For Each m In queryCollection
'Dim lvi As New ListViewItem
'lvi.Text = m("DisplayName").ToString
Try
Me.ListView1.Items.Add("Name")
Me.ListView1.Items(0).SubItems.Add(m("DisplayName").ToString)
Catch ex As Exception
Me.ListView1.Items.Add("Name")
Me.ListView1.Items(0).SubItems.Add(m("n.a."))
End Try
Try
Me.ListView1.Items.Add("Version")
Me.ListView1.Items(1).SubItems.Add(m("VersionNumber").ToString)
Catch ex As Exception
Me.ListView1.Items.Add("Version")
Me.ListView1.Items(1).SubItems.Add(m("n.a."))
End Try
Try
Me.ListView1.Items.Add("Company")
Me.ListView1.Items(2).SubItems.Add(m("CompanyName").ToString)
Catch ex As Exception
Me.ListView1.Items.Add("Company")
Me.ListView1.Items(2).SubItems.Add(m("n.a."))
End Try
Try
Me.ListView1.Items.Add("Product Upto date")
Me.ListView1.Items(3).SubItems.Add(m("productUptoDate").ToString)
Catch ex As Exception
Me.ListView1.Items.Add("Product Upto date")
Me.ListView1.Items(3).SubItems.Add(m("n.a."))
End Try
Try
Me.ListView1.Items.Add("On Access Scanning Enabled")
Me.ListView1.Items(4).SubItems.Add(m("onAccessScanningEnabled").ToString)
Catch ex As Exception
Me.ListView1.Items.Add("On Access Scanning Enabled")
Me.ListView1.Items(4).SubItems.Add(m("n.a."))
End Try
Application.DoEvents()
Next
For Each locColumn As ColumnHeader In Me.ListView1.Columns
locColumn.Width = -2
Next
Return "OK"
End Function
'Aufruf
'Punkt = Lokales System
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
LocalWin32_AVP(".")
End Sub
Kommentare zum Snippet