Willkommen bei dotnet-snippets.de! Snippet hinzufügen Login Registrieren
Snippets in der Datenbank: 1563 | Anzahl registrierter User: 1895 | Besucher online: 25
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 OHNE Registry Zugriff


Autor: Volker Steitz
Sprache: VB.NET
Bewertung:
8.76 (12 votes)
Anzahl der Aufrufe: 8996
  
Kick it on dotnet-kicks.de  

Beschreibung:

Manchmal benötigt man alle auf einem System installierten Codecs, kann oder darf jedoch nicht auf die Registry zugreifen.
In diesem Falle hilft WMI weiter.

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

Es kann entweder ein locales oder ein Remote_System abgefragt werden.

Da keine Logon-Credentials übergeben werden, funktioniert die Remote abfrage nur, wenn man auf dem Remote-System admin Rechte hat.

Es werden alle über die Codecs erhältlichen Infos ausgegeben.


Abgelegt unter: Codecs, WMI, Remote.



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
'Der nachfolgenden Funktion muss beim Aufruf 
'der Name des Abzufragenden Systems über-
'geben werden.
'Für das Lokale System geben sie bitte einen
'Punkt  .   ein.
'
'Die die Funktion benötigt ein Listview
'auf einem Formular mit Namen ListView1
'
'Aufruf beim Laden des Formulars:
'
'
LocalCodecsInfo(".")




Public Function LocalCodecsInfo(ByVal strComputer As String) As boolean
        Try
            Me.ListView1.Clear()
        Catch ex As Exception
        End Try


        Dim options As ConnectionOptions
        options = New ConnectionOptions()

        Dim scope As ManagementScope
        scope = New ManagementScope( _
            "\\" & strComputer & "\root\cimv2")
        scope.Connect()

        ' 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

       
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.)

Tim Hartwig schrieb am:  03.02.2007 01:40:32

Gut, hatte grad nicht an WMI gedacht. Und hier kann man sich noch mehr Infos holen als nur den Namen.
Georg Riha schrieb am:  12.02.2010 22:48:04

Liest aber nicht alle aus! Divx und cce wird zb. nicht angezeigt.


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