Willkommen bei dotnet-snippets.de! Snippet hinzufügen Login Registrieren
Snippets in der Datenbank: 1563 | Anzahl registrierter User: 1895 | Besucher online: 16
Hauptmenü
Home
Top Ten
Zufälliger Snippet
FAQs
.NET Community
dotnet-forum.de
dotnet-kicks.de
Social

RSS Feeds
Rss Alle Snippets
Rss C#
Rss VB.NET
Rss C++
Rss ASP.NET
Partner
Member of Microsoft Community Leader/Insider Program (CLIP)

Alle Codecs eines REMOTE Systems mit WMI


Autor: Volker Steitz
Sprache: VB.NET
Bewertung:
8.71 (10 votes)
Anzahl der Aufrufe: 7834
  
Kick it on dotnet-kicks.de  

Beschreibung:

Diese Funtion liest alle Informationen aus einem Remotesystem aus - diesmal mit der Übergabe von Username und Password.

Im folgenden werden alle auf einem Remote-System installierten Codecs ausgelesen und in einem Listview aufgelistet.

Es werden die folgenden Infos über die Codecs ausgegeben:

Name
Version
Group
Drive
Manufacturer
Archive
Encrypted
Extension
Filename
Filetype
Status


Abgelegt unter: WMI, Remote, Codecs.



Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
'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
Sie haben Fragen zu diesem Snippet oder brauchen Hilfe bei der .NET Entwicklung?
Freundliche und kompetente Entwickler helfen Ihnen gern weiter im Forum für .NET Entwicklung.



Kommentare:
(Zum Schreiben von Kommentaren bitte anmelden.)



schlecht sehr gut
1 2 3 4 5 6 7 8 9 10
Nur angemeldete User können Snippets bewerten.