ManagementClass.GetSubclasses 方法
定义
返回该类的所有派生类的集合。Returns the collection of all derived classes for the class.
重载
| 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. |
注解
.NET Framework 安全性.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()
返回类的所有子类的集合。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
返回
ManagementObject 对象的集合,这些对象表示 WMI 类的子类。A collection of the ManagementObject objects that represent the subclasses of the WMI class.
示例
下面的示例使用 GetSubclasses 方法将子类列出到 CIM_LogicalDisk 类。The following example uses the GetSubclasses method to list the subclasses to the CIM_LogicalDisk class. 有关详细信息,请参阅 CIM_LogicalDisk。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
注解
.NET Framework 安全性.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(EnumerationOptions)
使用指定选项检索类的子类。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
参数
- options
- EnumerationOptions
有关检索类的子类的指定附加选项。The specified additional options for retrieving subclasses of the class.
返回
ManagementObject 对象的集合,这些对象表示 WMI 类的子类(根据指定的选项)。A collection of the ManagementObject objects representing the subclasses of the WMI class, according to the specified options.
示例
下面的示例演示如何 ManagementClass 使用 ManagementClass 构造函数初始化变量,然后接收传入构造函数的 WMI 类的子类。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
注解
.NET Framework 安全性.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(ManagementOperationObserver)
异步返回从该类派生的所有类的集合。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)
参数
- watcher
- ManagementOperationObserver
处理异步操作进度的对象。The object to handle the asynchronous operation's progress.
注解
.NET Framework 安全性.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(ManagementOperationObserver, EnumerationOptions)
使用指定选项异步检索从该类派生的所有类。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)
参数
- watcher
- ManagementOperationObserver
处理异步操作进度的对象。The object to handle the asynchronous operation's progress.
- options
- EnumerationOptions
要用在派生类检索中的指定附加选项。The specified additional options to use in the derived class retrieval.
注解
.NET Framework 安全性.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.