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

返回

包含相关对象的 ManagementObjectCollectionA ManagementObjectCollection containing the related objects.

示例

下面的示例调用 GetRelated 方法来获取对象的集合,这些对象与 ManagementObject 类的实例相关。The 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 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.

返回

包含相关对象的 ManagementObjectCollectionA ManagementObjectCollection containing the related objects.

示例

下面的示例调用 GetRelated 方法来获取对象的集合,这些对象与 ManagementObject 类的实例相关。The 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.

返回

包含相关对象的 ManagementObjectCollectionA 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.

适用于