Bewerken

Delen via


ManagementClass.GetRelatedClasses Method

Definition

Retrieves classes related to the WMI class.

Overloads

GetRelatedClasses(ManagementOperationObserver, String, String, String, String, String, String, EnumerationOptions)

Retrieves classes related to the WMI class, asynchronously, using the specified options.

GetRelatedClasses(String, String, String, String, String, String, EnumerationOptions)

Retrieves classes related to the WMI class based on the specified options.

GetRelatedClasses(ManagementOperationObserver, String)

Retrieves classes related to the WMI class, asynchronously, given the related class name.

GetRelatedClasses(ManagementOperationObserver)

Retrieves classes related to the WMI class, asynchronously.

GetRelatedClasses()

Retrieves classes related to the WMI class.

GetRelatedClasses(String)

Retrieves classes related to the WMI class.

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.

GetRelatedClasses(ManagementOperationObserver, String, String, String, String, String, String, EnumerationOptions)

Source:
ManagementClass.cs
Source:
ManagementClass.cs
Source:
ManagementClass.cs
Source:
ManagementClass.cs

Retrieves classes related to the WMI class, asynchronously, using the specified options.

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

Parameters

watcher
ManagementOperationObserver

Handler for progress and results of the asynchronous operation.

relatedClass
String

The class from which resulting classes have to be derived.

relationshipClass
String

The relationship type which resulting classes must have with the source class.

relationshipQualifier
String

This qualifier must be present on the relationship.

relatedQualifier
String

This qualifier must be present on the resulting classes.

relatedRole
String

The resulting classes must have this role in the relationship.

thisRole
String

The source class must have this role in the relationship.

options
EnumerationOptions

The options for retrieving the resulting classes.

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

GetRelatedClasses(String, String, String, String, String, String, EnumerationOptions)

Source:
ManagementClass.cs
Source:
ManagementClass.cs
Source:
ManagementClass.cs
Source:
ManagementClass.cs

Retrieves classes related to the WMI class based on the specified options.

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

Parameters

relatedClass
String

The class from which resulting classes have to be derived.

relationshipClass
String

The relationship type which resulting classes must have with the source class.

relationshipQualifier
String

This qualifier must be present on the relationship.

relatedQualifier
String

This qualifier must be present on the resulting classes.

relatedRole
String

The resulting classes must have this role in the relationship.

thisRole
String

The source class must have this role in the relationship.

options
EnumerationOptions

The options for retrieving the resulting classes.

Returns

A collection of classes related to this class.

Examples

The following example uses the GetRelatedClasses method to list the related classes to the CIM_LogicalDisk class. For more information, see CIM_LogicalDisk.

using System;
using System.Management;

public class Sample
{
    public static void Main()
    {
        ManagementClass c =
            new ManagementClass("CIM_LogicalDisk");

        foreach (ManagementClass r in c.GetSubclasses())
        {
            Console.WriteLine(
                "Instances of {0} are sub-classes",
                r["__CLASS"]);
        }

        foreach (ManagementClass r in c.GetRelationshipClasses())
        {
            Console.WriteLine(
                "{0} is a relationship class to " +
                c.ClassPath.ClassName,
                r["__CLASS"]);

            foreach (ManagementClass related in c.GetRelatedClasses(
                null, r.ClassPath.ClassName,
                "Association", null, null, null, null))
            {
                Console.WriteLine(
                    "{0} is related to " + c.ClassPath.ClassName,
                    related.ClassPath.ClassName);
            }
        }

        return;
    }
}
Imports System.Management


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

        Dim c As ManagementClass
        c = New ManagementClass("CIM_LogicalDisk")

        For Each r As ManagementClass In c.GetSubclasses()

            Console.WriteLine( _
                "Instances of {0} are sub-classes", _
                r("__CLASS"))
        Next

        For Each r As ManagementClass In c.GetRelationshipClasses()

            Console.WriteLine( _
                "{0} is a relationship class to " & _
                c.ClassPath.ClassName, _
                r("__CLASS"))

            For Each related As ManagementClass In c.GetRelatedClasses( _
                Nothing, r.ClassPath.ClassName, "Association", Nothing, _
                Nothing, Nothing, Nothing)

                Console.WriteLine( _
                    "{0} is related to " & c.ClassPath.ClassName, _
                    related.ClassPath.ClassName)
            Next
        Next


    End Function
End Class

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

GetRelatedClasses(ManagementOperationObserver, String)

Source:
ManagementClass.cs
Source:
ManagementClass.cs
Source:
ManagementClass.cs
Source:
ManagementClass.cs

Retrieves classes related to the WMI class, asynchronously, given the related class name.

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

Parameters

watcher
ManagementOperationObserver

The object to handle the asynchronous operation's progress.

relatedClass
String

The name of the related class.

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

GetRelatedClasses(ManagementOperationObserver)

Source:
ManagementClass.cs
Source:
ManagementClass.cs
Source:
ManagementClass.cs
Source:
ManagementClass.cs

Retrieves classes related to the WMI class, asynchronously.

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

Parameters

watcher
ManagementOperationObserver

The object to handle the asynchronous operation's progress.

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

GetRelatedClasses()

Source:
ManagementClass.cs
Source:
ManagementClass.cs
Source:
ManagementClass.cs
Source:
ManagementClass.cs

Retrieves classes related to the WMI class.

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

Returns

A collection of the ManagementClass or ManagementObject objects that represents WMI classes or instances related to the WMI class.

Examples

The following example shows how to initialize a ManagementClass variable with a ManagementClass constructor and then list all the classes related to the WMI class passed into the constructor.

using System;
using System.Management;

public class Sample
{
    public static void Main()
    {
        ManagementClass c =
            new ManagementClass("Win32_LogicalDisk");

        foreach (ManagementClass r in c.GetRelatedClasses())
            Console.WriteLine(
                "Instances of {0} are related to this class",
                r["__CLASS"]);

        return;
    }
}
Imports System.Management

Public Class Sample

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

        Dim c As New ManagementClass("Win32_LogicalDisk")
        Dim r As ManagementClass

        For Each r In c.GetRelatedClasses()
            Console.WriteLine( _
                "Instances of {0} may have relationships " _
                & "to this class", r("__CLASS"))
        Next r
        Return 0
    End Function
End Class

Remarks

The method queries the WMI schema for all possible associations that the WMI class may have with other classes, or in rare cases, to instances. For more information about related classes, see ASSOCIATORS OF Statement.

.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

GetRelatedClasses(String)

Source:
ManagementClass.cs
Source:
ManagementClass.cs
Source:
ManagementClass.cs
Source:
ManagementClass.cs

Retrieves classes related to the WMI class.

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

Parameters

relatedClass
String

The class from which resulting classes have to be derived.

Returns

A collection of classes related to this class.

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