Читати англійською Редагувати

Поділитися через


ManagementObject.GetRelated Method

Definition

Gets a collection of objects related to the object (associators).

Overloads

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()

Source:
ManagementObject.cs
Source:
ManagementObject.cs
Source:
ManagementObject.cs

Gets a collection of objects related to the object (associators).

C#
public System.Management.ManagementObjectCollection GetRelated();

Returns

A ManagementObjectCollection containing the related objects.

Examples

The following example calls the GetRelated method to get a collection of objects related to an instance of the ManagementObject class.

C#
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);
    }
}

Remarks

The operation is equivalent to an ASSOCIATORS OF query where ResultClass = relatedClass.

.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.

Applies to

.NET 10 (package-provided) та інші версії
Продукт Версії
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

GetRelated(ManagementOperationObserver)

Source:
ManagementObject.cs
Source:
ManagementObject.cs
Source:
ManagementObject.cs

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.

C#
public void GetRelated(System.Management.ManagementOperationObserver watcher);

Parameters

watcher
ManagementOperationObserver

The object to use to return results.

Remarks

.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.

Applies to

.NET 10 (package-provided) та інші версії
Продукт Версії
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

GetRelated(String)

Source:
ManagementObject.cs
Source:
ManagementObject.cs
Source:
ManagementObject.cs

Gets a collection of objects related to the object (associators).

C#
public System.Management.ManagementObjectCollection GetRelated(string relatedClass);

Parameters

relatedClass
String

A class of related objects.

Returns

A ManagementObjectCollection containing the related objects.

Examples

The following example calls the GetRelated method to get a collection of objects related to an instance of the ManagementObject class.

C#
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"]);
    }
}

Remarks

.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.

Applies to

.NET 10 (package-provided) та інші версії
Продукт Версії
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

GetRelated(ManagementOperationObserver, String)

Source:
ManagementObject.cs
Source:
ManagementObject.cs
Source:
ManagementObject.cs

Gets a collection of objects related to the object (associators).

C#
public void GetRelated(System.Management.ManagementOperationObserver watcher, string relatedClass);

Parameters

watcher
ManagementOperationObserver

The object to use to return results.

relatedClass
String

The class of related objects.

Remarks

This operation is equivalent to an ASSOCIATORS OF query where ResultClass = relatedClass.

.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.

Applies to

.NET 10 (package-provided) та інші версії
Продукт Версії
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

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

Source:
ManagementObject.cs
Source:
ManagementObject.cs
Source:
ManagementObject.cs

Gets a collection of objects related to the object (associators).

C#
public System.Management.ManagementObjectCollection GetRelated(string relatedClass, string relationshipClass, string relationshipQualifier, string relatedQualifier, string relatedRole, string thisRole, bool classDefinitionsOnly, System.Management.EnumerationOptions options);

Parameters

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.

Returns

A ManagementObjectCollection containing the related objects.

Remarks

This operation is equivalent to an ASSOCIATORS OF query where ResultClass = relatedClass.

.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.

Applies to

.NET 10 (package-provided) та інші версії
Продукт Версії
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

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

Source:
ManagementObject.cs
Source:
ManagementObject.cs
Source:
ManagementObject.cs

Gets a collection of objects related to the object (associators).

C#
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);

Parameters

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.

Remarks

This operation is equivalent to an ASSOCIATORS OF query where ResultClass = relatedClass.

.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.

Applies to

.NET 10 (package-provided) та інші версії
Продукт Версії
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)