ManagementClass——ManagementClass 构造函数 (ManagementPath)

NET Framework 类库

ManagementClass 构造函数 (ManagementPath)

初始化 ManagementClass 类的新实例。该类表示 WMI 中的一个公共信息模型 (CIM) 管理类,如 Win32_LogicalDiskWin32_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 中)

C#
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 中。

path 参数必须指定一个 WMI 类路径。

.NET Framework 安全性

完全信任直接调用方。此成员不能由部分受信任的代码使用。有关更多信息,请参见 通过部分受信任的代码使用库

下面的示例演示如何使用 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 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

.NET Framework
受以下版本支持:2.0、1.1、1.0
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值