ManagementBaseObject.GetPropertyValue(String) 方法

定義

取得屬性值的對等存取子。

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

參數

propertyName
String

相關的屬性名稱。

傳回

指定之屬性的值。

範例

下列範例會列出在本機電腦上執行之進程的所有名稱。 程式碼會 GetPropertyValue 使用 方法來取得進程名稱。

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

備註

.NET Framework 安全性

完全信任立即呼叫者。 這個成員無法供部分信任的程式碼使用。 如需詳細資訊,請參閱 使用部分信任程式碼的程式庫

適用於