Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
GetRelatedClasses Method (String, String, String, String, String, String, EnumerationOptions)

ManagementClass.GetRelatedClasses Method (String, String, String, String, String, String, EnumerationOptions)

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

Namespace: System.Management
Assembly: System.Management (in system.management.dll)

public ManagementObjectCollection GetRelatedClasses (
	string relatedClass,
	string relationshipClass,
	string relationshipQualifier,
	string relatedQualifier,
	string relatedRole,
	string thisRole,
	EnumerationOptions options
)
public ManagementObjectCollection GetRelatedClasses (
	String relatedClass, 
	String relationshipClass, 
	String relationshipQualifier, 
	String relatedQualifier, 
	String relatedRole, 
	String thisRole, 
	EnumerationOptions options
)
public function GetRelatedClasses (
	relatedClass : String, 
	relationshipClass : String, 
	relationshipQualifier : String, 
	relatedQualifier : String, 
	relatedRole : String, 
	thisRole : String, 
	options : EnumerationOptions
) : ManagementObjectCollection

Parameters

relatedClass

The class from which resulting classes have to be derived.

relationshipClass

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

relationshipQualifier

This qualifier must be present on the relationship.

relatedQualifier

This qualifier must be present on the resulting classes.

relatedRole

The resulting classes must have this role in the relationship.

thisRole

The source class must have this role in the relationship.

options

The options for retrieving the resulting classes.

Return Value

A collection of classes related to this class.

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

The following example uses the GetRelatedClasses method to list the related classes to the CIM_LogicalDisk class. For more information, see "CIM_LogicalDisk" in the Windows Management Instrumentation documentation in the MSDN Library at http://msdn.microsoft.com/library.

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;
    }
}

  • Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see .

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2015 Microsoft