'Die die Funktion benötigt ein Listview
'auf einem Formular mit Namen ListView1
'
'Aufruf beim Laden des Formulars:
'
'
RemoteCodecsInfo(Systemname, Domainname, Password, Username)
'
'
'Verwenden Sie Active Directory, muss bei
'Domain der Domainname stehen, ansonsten
'muss bei Domain der Namen des
'Remotesystems stehen.
'
'
'Zusätzlich kann noch die Authentifizierungsmethode
'übergeben werden
'
Public Function RemoteCodecsInfo(ByVal _
strComputer As String, ByVal _
strDomain As String, ByVal _
strPwd As String, ByVal _
strUser As String) As String
Try
Me.ListView1.Clear()
Catch ex As Exception
End Try
Dim options As ConnectionOptions
options = New ConnectionOptions()
options.Username = strDomain & "\" & strUser
options.Password = strPwd
'options.Authority = "kerberos:" & strDomain
Dim scope As ManagementScope
scope = New ManagementScope( _
"\\" & strComputer & "\root\cimv2", options)
Try
scope.Connect()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error while Connecting", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
' Query system for Operating System information
Dim query As ObjectQuery
query = New ObjectQuery( _
"SELECT * FROM Win32_CodecFile")
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
Me.ListView1.Columns.Add("Name", 10, HorizontalAlignment.Left)
Me.ListView1.Columns.Add("Version", 10, HorizontalAlignment.Left)
Me.ListView1.Columns.Add("Group", 10, HorizontalAlignment.Left)
Me.ListView1.Columns.Add("Drive", 10, HorizontalAlignment.Left)
Me.ListView1.Columns.Add("Manufacturer", 10, HorizontalAlignment.Left)
Me.ListView1.Columns.Add("Archive", 10, HorizontalAlignment.Left)
Me.ListView1.Columns.Add("Encrypted", 10, HorizontalAlignment.Left)
Me.ListView1.Columns.Add("Extension", 10, HorizontalAlignment.Left)
Me.ListView1.Columns.Add("Filename", 10, HorizontalAlignment.Left)
Me.ListView1.Columns.Add("Filetype", 10, HorizontalAlignment.Left)
Me.ListView1.Columns.Add("Status", 10, HorizontalAlignment.Left)
For Each m In queryCollection
'Display the remote computer information
Dim lvi As New ListViewItem
lvi.Text = m("Name").ToString
Try
lvi.SubItems.Add(m("Version").ToString)
Catch ex As Exception
lvi.SubItems.Add("")
End Try
Try
lvi.SubItems.Add(m("Group").ToString)
Catch ex As Exception
lvi.SubItems.Add("")
End Try
Try
lvi.SubItems.Add(m("Drive").ToString)
Catch ex As Exception
lvi.SubItems.Add("")
End Try
Try
lvi.SubItems.Add(m("Manufacturer").ToString)
Catch ex As Exception
lvi.SubItems.Add("")
End Try
Try
lvi.SubItems.Add(m("Archive").ToString)
Catch ex As Exception
lvi.SubItems.Add("")
End Try
Try
lvi.SubItems.Add(m("Encrypted").ToString)
Catch ex As Exception
lvi.SubItems.Add("")
End Try
Try
lvi.SubItems.Add(m("Extension").ToString)
Catch ex As Exception
lvi.SubItems.Add("")
End Try
Try
lvi.SubItems.Add(m("FileName").ToString)
Catch ex As Exception
lvi.SubItems.Add("")
End Try
Try
lvi.SubItems.Add(m("Filetype").ToString)
Catch ex As Exception
lvi.SubItems.Add("")
End Try
Try
lvi.SubItems.Add(m("Status").ToString)
Catch ex As Exception
lvi.SubItems.Add("")
End Try
Me.ListView1.Items.Add(lvi)
Application.DoEvents()
Next
For Each locColumn As ColumnHeader In Me.ListView1.Columns
locColumn.Width = -2
Next
Return "OK"
End Function