ManagementObject.GetRelated 方法

定義

取得與物件 (相關者) 相關的物件集合。

多載

GetRelated()

取得與物件 (相關者) 相關的物件集合。

GetRelated(ManagementOperationObserver)

非同步取得與物件 (相關者) 相關的物件集合。 這個呼叫會立即傳回,當結果可以使用時,會呼叫委派。

GetRelated(String)

取得與物件 (相關者) 相關的物件集合。

GetRelated(ManagementOperationObserver, String)

取得與物件 (相關者) 相關的物件集合。

GetRelated(String, String, String, String, String, String, Boolean, EnumerationOptions)

取得與物件 (相關者) 相關的物件集合。

GetRelated(ManagementOperationObserver, String, String, String, String, String, String, Boolean, EnumerationOptions)

取得與物件 (相關者) 相關的物件集合。

GetRelated()

取得與物件 (相關者) 相關的物件集合。

public:
 System::Management::ManagementObjectCollection ^ GetRelated();
public System.Management.ManagementObjectCollection GetRelated ();
member this.GetRelated : unit -> System.Management.ManagementObjectCollection
Public Function GetRelated () As ManagementObjectCollection

傳回

ManagementObjectCollection

ManagementObjectCollection,包含關聯的物件。

範例

下列範例會 GetRelated 呼叫 方法,以取得與 類別實例 ManagementObject 相關的物件集合。

using System;
using System.Management;

public class Sample
{
    public static void Main(string[] args)
    {
        ManagementObject o =
            new ManagementObject("Win32_Service='Alerter'");

        foreach(ManagementObject b in o.GetRelated())
            Console.WriteLine(
                "Object related to Alerter service : {0}",
                b.ClassPath);
    }
}
Imports System.Management


Class Sample_ManagementClass

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


        Dim o As New ManagementObject( _
        "Win32_Service=""Alerter""")

        Dim b As ManagementObject
        For Each b In o.GetRelated()
            Console.WriteLine( _
            "Object related to Alerter service : {0}", _
            b.ClassPath)
        Next b

        Return 0
    End Function

End Class

備註

作業相當於 RESULTClass = relatedClass 的 ASSOCIATORS OF 查詢。

.NET Framework 安全性

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

適用於

GetRelated(ManagementOperationObserver)

非同步取得與物件 (相關者) 相關的物件集合。 這個呼叫會立即傳回,當結果可以使用時,會呼叫委派。

public:
 void GetRelated(System::Management::ManagementOperationObserver ^ watcher);
public void GetRelated (System.Management.ManagementOperationObserver watcher);
member this.GetRelated : System.Management.ManagementOperationObserver -> unit
Public Sub GetRelated (watcher As ManagementOperationObserver)

參數

watcher
ManagementOperationObserver

用來傳回結果的物件。

備註

.NET Framework 安全性

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

適用於

GetRelated(String)

取得與物件 (相關者) 相關的物件集合。

public:
 System::Management::ManagementObjectCollection ^ GetRelated(System::String ^ relatedClass);
public System.Management.ManagementObjectCollection GetRelated (string relatedClass);
member this.GetRelated : string -> System.Management.ManagementObjectCollection
Public Function GetRelated (relatedClass As String) As ManagementObjectCollection

參數

relatedClass
String

相關物件的類別。

傳回

ManagementObjectCollection

ManagementObjectCollection,包含關聯的物件。

範例

下列範例會 GetRelated 呼叫 方法,以取得與 類別實例 ManagementObject 相關的物件集合。

using System;
using System.Management;

public class Sample
{
    public static void Main(string[] args)
    {
        ManagementObject o =
            new ManagementObject("Win32_Service='Alerter'");

        foreach (ManagementObject b in
            o.GetRelated("Win32_Service"))

            Console.WriteLine(
                "Service related to the Alerter service {0} is {1}",
                b["Name"], b["State"]);
    }
}
Imports System.Management

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

        Dim o As New ManagementObject( _
            "Win32_Service=""Alerter""")
        Dim b As ManagementObject
        For Each b In o.GetRelated("Win32_Service")
            Console.WriteLine( _
            "Service related to the Alerter service {0} is {1}", _
            b("Name"), b("State"))
        Next b

        Return 0
    End Function
End Class

備註

.NET Framework 安全性

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

適用於

GetRelated(ManagementOperationObserver, String)

取得與物件 (相關者) 相關的物件集合。

public:
 void GetRelated(System::Management::ManagementOperationObserver ^ watcher, System::String ^ relatedClass);
public void GetRelated (System.Management.ManagementOperationObserver watcher, string relatedClass);
member this.GetRelated : System.Management.ManagementOperationObserver * string -> unit
Public Sub GetRelated (watcher As ManagementOperationObserver, relatedClass As String)

參數

watcher
ManagementOperationObserver

用來傳回結果的物件。

relatedClass
String

相關物件的類別。

備註

這項作業相當於 RESULTClass = relatedClass 的 ASSOCIATORS OF 查詢。

.NET Framework 安全性

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

適用於

GetRelated(String, String, String, String, String, String, Boolean, EnumerationOptions)

取得與物件 (相關者) 相關的物件集合。

public:
 System::Management::ManagementObjectCollection ^ GetRelated(System::String ^ relatedClass, System::String ^ relationshipClass, System::String ^ relationshipQualifier, System::String ^ relatedQualifier, System::String ^ relatedRole, System::String ^ thisRole, bool classDefinitionsOnly, System::Management::EnumerationOptions ^ options);
public System.Management.ManagementObjectCollection GetRelated (string relatedClass, string relationshipClass, string relationshipQualifier, string relatedQualifier, string relatedRole, string thisRole, bool classDefinitionsOnly, System.Management.EnumerationOptions options);
member this.GetRelated : string * string * string * string * string * string * bool * System.Management.EnumerationOptions -> System.Management.ManagementObjectCollection
Public Function GetRelated (relatedClass As String, relationshipClass As String, relationshipQualifier As String, relatedQualifier As String, relatedRole As String, thisRole As String, classDefinitionsOnly As Boolean, options As EnumerationOptions) As ManagementObjectCollection

參數

relatedClass
String

相關物件的類別。

relationshipClass
String

相關的關聯性類別。

relationshipQualifier
String

限定詞,必須出現在關聯性類別上。

relatedQualifier
String

限定詞,必須出現在相關聯類別上。

relatedRole
String

相關類別在關聯性中正在扮演的角色。

thisRole
String

這個類別在關聯性中正在扮演的角色。

classDefinitionsOnly
Boolean

這個方法傳回時,只包含符合查詢的執行個體的類別定義。

options
EnumerationOptions

有關如何執行查詢的擴充選項。

傳回

ManagementObjectCollection

ManagementObjectCollection,包含關聯的物件。

備註

這項作業相當於 RESULTClass = relatedClass 的 ASSOCIATORS OF 查詢。

.NET Framework 安全性

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

適用於

GetRelated(ManagementOperationObserver, String, String, String, String, String, String, Boolean, EnumerationOptions)

取得與物件 (相關者) 相關的物件集合。

public:
 void GetRelated(System::Management::ManagementOperationObserver ^ watcher, System::String ^ relatedClass, System::String ^ relationshipClass, System::String ^ relationshipQualifier, System::String ^ relatedQualifier, System::String ^ relatedRole, System::String ^ thisRole, bool classDefinitionsOnly, System::Management::EnumerationOptions ^ options);
public void GetRelated (System.Management.ManagementOperationObserver watcher, string relatedClass, string relationshipClass, string relationshipQualifier, string relatedQualifier, string relatedRole, string thisRole, bool classDefinitionsOnly, System.Management.EnumerationOptions options);
member this.GetRelated : System.Management.ManagementOperationObserver * string * string * string * string * string * string * bool * System.Management.EnumerationOptions -> unit
Public Sub GetRelated (watcher As ManagementOperationObserver, relatedClass As String, relationshipClass As String, relationshipQualifier As String, relatedQualifier As String, relatedRole As String, thisRole As String, classDefinitionsOnly As Boolean, options As EnumerationOptions)

參數

watcher
ManagementOperationObserver

用來傳回結果的物件。

relatedClass
String

相關物件的類別。

relationshipClass
String

相關的關聯性類別。

relationshipQualifier
String

限定詞,必須出現在關聯性類別上。

relatedQualifier
String

限定詞,必須出現在相關聯類別上。

relatedRole
String

相關類別在關聯性中正在扮演的角色。

thisRole
String

這個類別在關聯性中正在扮演的角色。

classDefinitionsOnly
Boolean

只傳回符合查詢的執行個體的類別定義。

options
EnumerationOptions

有關如何執行查詢的擴充選項。

備註

這項作業相當於 RESULTClass = relatedClass 的 ASSOCIATORS OF 查詢。

.NET Framework 安全性

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

適用於