ManagementObject.GetRelated 方法

定義

取得與物件 (相關者) 相關的物件集合。Gets a collection of objects related to the object (associators).

多載

GetRelated()

取得與物件 (相關者) 相關的物件集合。Gets a collection of objects related to the object (associators).

GetRelated(ManagementOperationObserver)

非同步取得與物件 (相關者) 相關的物件集合。Gets a collection of objects related to the object (associators) asynchronously. 這個呼叫會立即傳回,當結果可以使用時,會呼叫委派。This call returns immediately, and a delegate is called when the results are available.

GetRelated(String)

取得與物件 (相關者) 相關的物件集合。Gets a collection of objects related to the object (associators).

GetRelated(ManagementOperationObserver, String)

取得與物件 (相關者) 相關的物件集合。Gets a collection of objects related to the object (associators).

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

取得與物件 (相關者) 相關的物件集合。Gets a collection of objects related to the object (associators).

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

取得與物件 (相關者) 相關的物件集合。Gets a collection of objects related to the object (associators).

GetRelated()

取得與物件 (相關者) 相關的物件集合。Gets a collection of objects related to the object (associators).

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

傳回

ManagementObjectCollection

ManagementObjectCollection,包含關聯的物件。A ManagementObjectCollection containing the related objects.

範例

下列範例會呼叫 GetRelated 方法,以取得與類別實例相關的物件集合 ManagementObjectThe following example calls the GetRelated method to get a collection of objects related to an instance of the ManagementObject class.

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

備註

作業相當於 ASSOCIATORS OF 的 查詢,其中 ResultClass = relatedClass。The operation is equivalent to an ASSOCIATORS OF query where ResultClass = relatedClass.

.NET Framework 安全性.NET Framework Security

完全信任立即呼叫者。Full trust for the immediate caller. 這個成員無法供部分信任的程式碼使用。This member cannot be used by partially trusted code. 如需詳細資訊,請參閱 使用來自部分信任程式碼的程式庫For more information, see Using Libraries from Partially Trusted Code.

適用於

GetRelated(ManagementOperationObserver)

非同步取得與物件 (相關者) 相關的物件集合。Gets a collection of objects related to the object (associators) asynchronously. 這個呼叫會立即傳回,當結果可以使用時,會呼叫委派。This call returns immediately, and a delegate is called when the results are available.

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

用來傳回結果的物件。The object to use to return results.

備註

.NET Framework 安全性.NET Framework Security

完全信任立即呼叫者。Full trust for the immediate caller. 這個成員無法供部分信任的程式碼使用。This member cannot be used by partially trusted code. 如需詳細資訊,請參閱 使用來自部分信任程式碼的程式庫For more information, see Using Libraries from Partially Trusted Code.

適用於

GetRelated(String)

取得與物件 (相關者) 相關的物件集合。Gets a collection of objects related to the object (associators).

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

相關物件的類別。A class of related objects.

傳回

ManagementObjectCollection

ManagementObjectCollection,包含關聯的物件。A ManagementObjectCollection containing the related objects.

範例

下列範例會呼叫 GetRelated 方法,以取得與類別實例相關的物件集合 ManagementObjectThe following example calls the GetRelated method to get a collection of objects related to an instance of the ManagementObject class.

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 安全性.NET Framework Security

完全信任立即呼叫者。Full trust for the immediate caller. 這個成員無法供部分信任的程式碼使用。This member cannot be used by partially trusted code. 如需詳細資訊,請參閱 使用來自部分信任程式碼的程式庫For more information, see Using Libraries from Partially Trusted Code.

適用於

GetRelated(ManagementOperationObserver, String)

取得與物件 (相關者) 相關的物件集合。Gets a collection of objects related to the object (associators).

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

用來傳回結果的物件。The object to use to return results.

relatedClass
String

相關物件的類別。The class of related objects.

備註

這項作業相當於 ASSOCIATORS OF 的 查詢,其中 ResultClass = relatedClass。This operation is equivalent to an ASSOCIATORS OF query where ResultClass = relatedClass.

.NET Framework 安全性.NET Framework Security

完全信任立即呼叫者。Full trust for the immediate caller. 這個成員無法供部分信任的程式碼使用。This member cannot be used by partially trusted code. 如需詳細資訊,請參閱 使用來自部分信任程式碼的程式庫For more information, see Using Libraries from Partially Trusted Code.

適用於

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

取得與物件 (相關者) 相關的物件集合。Gets a collection of objects related to the object (associators).

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

相關物件的類別。The class of the related objects.

relationshipClass
String

相關的關聯性類別。The relationship class of interest.

relationshipQualifier
String

限定詞,必須出現在關聯性類別上。The qualifier required to be present on the relationship class.

relatedQualifier
String

限定詞,必須出現在相關聯類別上。The qualifier required to be present on the related class.

relatedRole
String

相關類別在關聯性中正在扮演的角色。The role that the related class is playing in the relationship.

thisRole
String

這個類別在關聯性中正在扮演的角色。The role that this class is playing in the relationship.

classDefinitionsOnly
Boolean

這個方法傳回時,只包含符合查詢的執行個體的類別定義。When this method returns, it contains only class definitions for the instances that match the query.

options
EnumerationOptions

有關如何執行查詢的擴充選項。Extended options for how to execute the query.

傳回

ManagementObjectCollection

ManagementObjectCollection,包含關聯的物件。A ManagementObjectCollection containing the related objects.

備註

這項作業相當於 ASSOCIATORS OF 的 查詢,其中 ResultClass = relatedClass。This operation is equivalent to an ASSOCIATORS OF query where ResultClass = relatedClass.

.NET Framework 安全性.NET Framework Security

完全信任立即呼叫者。Full trust for the immediate caller. 這個成員無法供部分信任的程式碼使用。This member cannot be used by partially trusted code. 如需詳細資訊,請參閱 使用來自部分信任程式碼的程式庫For more information, see Using Libraries from Partially Trusted Code.

適用於

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

取得與物件 (相關者) 相關的物件集合。Gets a collection of objects related to the object (associators).

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

用來傳回結果的物件。The object to use to return results.

relatedClass
String

相關物件的類別。The class of the related objects.

relationshipClass
String

相關的關聯性類別。The relationship class of interest.

relationshipQualifier
String

限定詞,必須出現在關聯性類別上。The qualifier required to be present on the relationship class.

relatedQualifier
String

限定詞,必須出現在相關聯類別上。The qualifier required to be present on the related class.

relatedRole
String

相關類別在關聯性中正在扮演的角色。The role that the related class is playing in the relationship.

thisRole
String

這個類別在關聯性中正在扮演的角色。The role that this class is playing in the relationship.

classDefinitionsOnly
Boolean

只傳回符合查詢的執行個體的類別定義。Return only class definitions for the instances that match the query.

options
EnumerationOptions

有關如何執行查詢的擴充選項。Extended options for how to execute the query.

備註

這項作業相當於 ASSOCIATORS OF 的 查詢,其中 ResultClass = relatedClass。This operation is equivalent to an ASSOCIATORS OF query where ResultClass = relatedClass.

.NET Framework 安全性.NET Framework Security

完全信任立即呼叫者。Full trust for the immediate caller. 這個成員無法供部分信任的程式碼使用。This member cannot be used by partially trusted code. 如需詳細資訊,請參閱 使用來自部分信任程式碼的程式庫For more information, see Using Libraries from Partially Trusted Code.

適用於