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 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
Type: System.String

The class from which resulting classes have to be derived.

relationshipClass
Type: System.String

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

relationshipQualifier
Type: System.String

This qualifier must be present on the relationship.

relatedQualifier
Type: System.String

This qualifier must be present on the resulting classes.

relatedRole
Type: System.String

The resulting classes must have this role in the relationship.

thisRole
Type: System.String

The source class must have this role in the relationship.

options
Type: System.Management.EnumerationOptions

The options for retrieving the resulting classes.

Return Value

Type: System.Management.ManagementObjectCollection

A collection of classes related to this class.

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.

Imports System
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

.NET Framework
Available since 1.1
Return to top
Show: