ManagementClass.GetSubclasses Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns the collection of all derived classes for the class.
Overloads
GetSubclasses() |
Returns the collection of all subclasses for the class. |
GetSubclasses(EnumerationOptions) |
Retrieves the subclasses of the class using the specified options. |
GetSubclasses(ManagementOperationObserver) |
Returns the collection of all classes derived from this class, asynchronously. |
GetSubclasses(ManagementOperationObserver, EnumerationOptions) |
Retrieves all classes derived from this class, asynchronously, using the specified options. |
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.
GetSubclasses()
- Source:
- ManagementClass.cs
- Source:
- ManagementClass.cs
- Source:
- ManagementClass.cs
Returns the collection of all subclasses for the class.
public:
System::Management::ManagementObjectCollection ^ GetSubclasses();
public System.Management.ManagementObjectCollection GetSubclasses ();
member this.GetSubclasses : unit -> System.Management.ManagementObjectCollection
Public Function GetSubclasses () As ManagementObjectCollection
Returns
A collection of the ManagementObject objects that represent the subclasses of the WMI class.
Examples
The following example uses the GetSubclasses method to list the subclasses 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
GetSubclasses(EnumerationOptions)
- Source:
- ManagementClass.cs
- Source:
- ManagementClass.cs
- Source:
- ManagementClass.cs
Retrieves the subclasses of the class using the specified options.
public:
System::Management::ManagementObjectCollection ^ GetSubclasses(System::Management::EnumerationOptions ^ options);
public System.Management.ManagementObjectCollection GetSubclasses (System.Management.EnumerationOptions options);
member this.GetSubclasses : System.Management.EnumerationOptions -> System.Management.ManagementObjectCollection
Public Function GetSubclasses (options As EnumerationOptions) As ManagementObjectCollection
Parameters
- options
- EnumerationOptions
The specified additional options for retrieving subclasses of the class.
Returns
A collection of the ManagementObject objects representing the subclasses of the WMI class, according to the specified options.
Examples
The following example shows how to initialize a ManagementClass variable with a ManagementClass constructor and then receive the subclasses of the WMI class passed into the constructor.
using System;
using System.Management;
public class Example
{
public static void Main()
{
EnumerationOptions opt = new EnumerationOptions();
// Causes return of deep subclasses
// as opposed to only immediate ones.
opt.EnumerateDeep = true;
ManagementObjectCollection subclasses = (new
ManagementClass("CIM_LogicalDisk")).GetSubclasses(opt);
foreach(ManagementClass subclass in subclasses)
{
Console.WriteLine( "Subclass found: {0}" ,
subclass["__CLASS"]);
}
return;
}
}
Imports System.Management
Public Class Sample
Public Shared Function Main(ByVal args() _
As String) As Integer
Dim opt As New EnumerationOptions
' Causes return of deep subclasses
' as opposed to only immediate ones.
opt.EnumerateDeep = True
Dim cls As New ManagementClass("CIM_LogicalDisk")
Dim subclasses As ManagementObjectCollection
subclasses = cls.GetSubclasses(opt)
For Each subclass As ManagementClass In subclasses
Console.WriteLine("Subclass found: {0}", _
subclass("__CLASS"))
Next
Return 0
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
GetSubclasses(ManagementOperationObserver)
- Source:
- ManagementClass.cs
- Source:
- ManagementClass.cs
- Source:
- ManagementClass.cs
Returns the collection of all classes derived from this class, asynchronously.
public:
void GetSubclasses(System::Management::ManagementOperationObserver ^ watcher);
public void GetSubclasses (System.Management.ManagementOperationObserver watcher);
member this.GetSubclasses : System.Management.ManagementOperationObserver -> unit
Public Sub GetSubclasses (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
GetSubclasses(ManagementOperationObserver, EnumerationOptions)
- Source:
- ManagementClass.cs
- Source:
- ManagementClass.cs
- Source:
- ManagementClass.cs
Retrieves all classes derived from this class, asynchronously, using the specified options.
public:
void GetSubclasses(System::Management::ManagementOperationObserver ^ watcher, System::Management::EnumerationOptions ^ options);
public void GetSubclasses (System.Management.ManagementOperationObserver watcher, System.Management.EnumerationOptions options);
member this.GetSubclasses : System.Management.ManagementOperationObserver * System.Management.EnumerationOptions -> unit
Public Sub GetSubclasses (watcher As ManagementOperationObserver, options As EnumerationOptions)
Parameters
- watcher
- ManagementOperationObserver
The object to handle the asynchronous operation's progress.
- options
- EnumerationOptions
The specified additional options to use in the derived class retrieval.
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.