NET Framework 类库
初始化 ManagementClass 类的新实例。该类表示 WMI 中的一个公共信息模型 (CIM) 管理类,如 Win32_LogicalDisk 和 Win32_Process,前者表示磁盘驱动器,后者表示进程(如 Notepad.exe)。有关更多信息,请参见“Windows Management Instrumentation”文档中的“Win32 Classes”(Win32 类),该文档位于 http://www.microsoft.com/china/msdn/library 上的 MSDN Library 中。
命名空间:System.Management
程序集:System.Management(在 system.management.dll 中)
public ManagementClass (
ManagementPath path
)
参数
-
path
-
ManagementPath,它指定要绑定到哪个 WMI 类。参数必须指定一个 WMI 类路径。该类表示 WMI 中的一个 CIM 管理类。CIM 类表示包括硬件、软件、进程等在内的管理信息。有关 Windows 中可用的 CIM 类的更多信息,请参见“Windows Management Instrumentation”文档中的“Win32 Classes”(Win32 类),该文档位于 http://www.microsoft.com/china/msdn/library 上的 MSDN Library 中。
下面的示例演示如何使用 ManagementClass 构造函数初始化 ManagementClass 变量。该示例列出已创建的类的方法、属性和限定符。
using System; using System.Management; public class Sample { public static void Main() { // Get the WMI class ManagementClass c = new ManagementClass( new ManagementPath("Win32_LogicalDisk")); // Get the methods in the class MethodDataCollection methods = c.Methods; // display the methods Console.WriteLine("Method Names: "); foreach (MethodData method in methods) { Console.WriteLine(method.Name); } Console.WriteLine(); // Get the properties in the class PropertyDataCollection properties = c.Properties; // display the properties Console.WriteLine("Property Names: "); foreach (PropertyData property in properties) { Console.WriteLine(property.Name); } Console.WriteLine(); // Get the Qualifiers in the class QualifierDataCollection qualifiers = c.Qualifiers; // display the qualifiers Console.WriteLine("Qualifier Names: "); foreach (QualifierData qualifier in qualifiers) { Console.WriteLine(qualifier.Name); } } }
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
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。