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 中)

 语法
Visual Basic(声明)
Public Sub New ( _
path As ManagementPath _
)

Visual Basic(用法)
Dim path As ManagementPath
Dim instance As New ManagementClass(path)

C#
public ManagementClass (
ManagementPath path
)

C++
public:
ManagementClass (
ManagementPath^ path
)

J#
public ManagementClass (
ManagementPath path
)

JScript
public function ManagementClass (
path : ManagementPath
)

参数

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 变量。该示例列出已创建的类的方法、属性和限定符。

Visual Basic
复制代码

Imports System
Imports System.Management
Class Sample
Public Overloads Shared Function _
Main(ByVal args() As String) As Integer
' Get the WMI class
Dim c As New ManagementClass( _
New ManagementPath("Win32_LogicalDisk"))
' Get the methods in the class
Dim methods As MethodDataCollection
methods = c.Methods
' display the methods
Console.WriteLine("Method Names: ")
For Each method As MethodData In methods
Console.WriteLine(method.Name)
Next
Console.WriteLine()
' Get the properties in the class
Dim properties As PropertyDataCollection
properties = c.Properties
' display the properties
Console.WriteLine("Property Names: ")
For Each p As PropertyData In properties
Console.WriteLine(p.Name)
Next
Console.WriteLine()
' Get the Qualifiers in the class
Dim qualifiers As QualifierDataCollection = _
c.Qualifiers()
' display the qualifiers
Console.WriteLine("Qualifier Names: ")
For Each qualifier As QualifierData In qualifiers
Console.WriteLine(qualifier.Name)
Next
End Function
End Class

C#
复制代码

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);
}
}
}

 .NET Framework 安全性
  • 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见。

 平台

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

ManagementClass——ManagementClass 构造函数 (ManagementPath)相关推荐

  1. C#控制远程计算机的服务

    在.net中提供了一些类来显示和控制Windows系统上的服务,并可以实现对远程计算机服务服务的访问,如System.ServiceProcess命名空间下面的ServiceController 类, ...

  2. 如何用VS2005制作Web安装程序

    网站完成后,需要部署到目标机器上,方法有很多,直接把文件Copy到目标机器上,执行SQL脚本,配置IIS,这样可以做到:也可以使用InstallShield这样到专业制作软件来打包.本篇文章是使用VS ...

  3. [转]如何用VS2005制作Web安装程序

    本文转自:http://blog.csdn.net/cqfeng/archive/2006/02/17/601506.aspx 原文如下: ------- 网站完成后,需要部署到目标机器上,方法有很多 ...

  4. 使用C#控制远程计算机的服务[转]

    在.net中提供了一些类来显示和控制Windows系统上的服务,并可以实现对远程计算机服务服务的访问,如 System.ServiceProcess命名空间下面的ServiceController 类 ...

  5. 用VS2005制作网页对IIS进行操作

    主要是想用一下VS2005,对IIS的操作在IIS Admin中本来就可以进行管理.所以将就看,无所谓有用无用哈.^_^ 在网上也找了一下,参考了一些别人的写法,如果有什么不对的,请你多指点. 本文只 ...

  6. 管理远程计算机服务,C#中控制远程计算机的服务的方法

    C#中控制远程计算机的服务的方法 更新时间:2007年04月16日 00:00:00   作者: 在.net中提供了一些类来显示和控制Windows系统上的服务,并可以实现对远程计算机服务服务的访问, ...

  7. C#实现软件授权,限定MAC运行(软件license管理,简单软件注册机制)

    一个绿色免安装软件,领导临时要求加个注册机制,不能让现场工程师随意复制.事出突然,只能在现场开发(离开现场软件就不受我们控了).花了不到两个小时实现了简单的注册机制,稍作整理.  基本原理:1.软件一 ...

  8. C#软件授权、注册、加密、解密模块源码解析并制作注册机生成license

    最近做了一个绿色免安装软件,领导临时要求加个注册机制,不能让现场工程师随意复制.事出突然,只能在现场开发(离开现场软件就不受我们控了).花了不到两个小时实现了简单的注册机制,稍作整理.         ...

  9. C#软件license管理(简单软件注册机制)

    最近做了一个绿色免安装软件,领导临时要求加个注册机制,不能让现场工程师随意复制.事出突然,只能在现场开发(离开现场软件就不受我们控了).花了不到两个小时实现了简单的注册机制,稍作整理.         ...

最新文章

  1. Qt中的TCP客户端编程
  2. Excel完成将多行多列数据转化为一列
  3. “引用作为函数参数”与 “引用作为函数返回值”
  4. Python3——JSON
  5. 直播丨分布式数据库:从PG-XL到TBASE
  6. 操作系统系列题型分析(更新中~)
  7. 微型计算机的字长不一定是字节的整数倍数,2015江苏省全国计算机等级考试二级VB笔试试卷及参考答案考试技巧重点...
  8. 静态页面对seo优化之详解
  9. 国二python考试时间_计算机国二报名每年在几月份
  10. 迅雷离线下载 docker
  11. 腐烂国度计算机配置要求,腐烂国度一周年求生版配置要求 略有小幅度提升
  12. 使用SendCloud企业发送邮件
  13. Spring理论--Spring MVC学习
  14. require.context()的用法
  15. 华为鸿蒙pc系统试用版,华为开源操作系统 鸿蒙OS 升级版曝光,打通PC等一大批硬件...
  16. windows phone 7---8 Belling's课堂(十五) 程序等待页面的处理
  17. vue-router路由有几种模式?说说它们的区别?
  18. 小陈学js 预解析
  19. 数据开发面试问题记录
  20. mfc: 获取打印机列表

热门文章

  1. 格式化字符串替换2022/8/2am
  2. root改名字,root重命名
  3. oracle 中的 CONCAT,substring ,MINUS 用法
  4. 618查看商品历史价格的方法
  5. CoreData用法二:NSFetchedResultsController实例操作与讲解
  6. 缠论 python 量化_【JoinQuant聚宽社区干货】量化学习资料、经典交易策略、Python入门...
  7. java 打印byte数组内容_java中打印byte数组
  8. 世界顶级黑客大赛内情首次揭秘:有“连环计”,最后一刻把“韩国队”拉下马...
  9. 任务管理器被管理员禁用_为什么禁用任务管理器?
  10. SQL注入漏洞-绕过