ManagementBaseObject.GetPropertyValue(String) Metoda

Definicja

Pobiera odpowiednik metody dostępu do wartości właściwości.

public:
 System::Object ^ GetPropertyValue(System::String ^ propertyName);
public object GetPropertyValue (string propertyName);
member this.GetPropertyValue : string -> obj
Public Function GetPropertyValue (propertyName As String) As Object

Parametry

propertyName
String

Nazwa właściwości, która jest zainteresowana.

Zwraca

Wartość określonej właściwości.

Przykłady

W poniższym przykładzie wymieniono wszystkie nazwy procesów uruchomionych na komputerze lokalnym. Kod używa GetPropertyValue metody do pobierania nazw procesów.

using System;
using System.Management;

public class Sample
{
    public static void Main()
    {

        // Get the WMI class
        ManagementClass processClass =
            new ManagementClass("Win32_Process");

        ManagementObjectCollection classObjects;
        classObjects = processClass.GetInstances();

        foreach (ManagementObject classObject in
            classObjects)
        {
            Console.WriteLine(
                classObject.GetPropertyValue(
                "Name"));
        }
    }
}
Imports System.Management


Class Sample
    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer

        ' Get the WMI class
        Dim processClass As New ManagementClass( _
            "Win32_Process")

        Dim classObjects As ManagementObjectCollection
        classObjects = processClass.GetInstances()

        For Each classObject As ManagementObject _
            In classObjects

            Console.WriteLine( _
                classObject.GetPropertyValue( _
                    "Name"))

        Next

    End Function
End Class

Uwagi

Zabezpieczenia.NET Framework

Pełne zaufanie do bezpośredniego wywołującego. Ten element członkowski nie może być używany przez kod częściowo zaufany. Aby uzyskać więcej informacji, zobacz Using Libraries from Partially Trusted Code (Używanie bibliotek z częściowo zaufanego kodu).

Dotyczy