大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> NET专区 -> 使用WMI获得硬盘的信息

使用WMI获得硬盘的信息

时间: 2021-07-31 作者:daque

开始,什么是wmi? wmi(windows处置框架结构:windows management instrumentation)是microsoft鉴于web的企业处置(wbem)和 desktop management task force(dmtf)产业规范的实行. 即是一种鉴于规范的体例处置的开拓接口,这组接口用来遏制处置计划机. 它供给了一种大略的本领来处置和遏制体例资源. 即使你想深刻领会他,不妨参考micorosft platform sdk . 在这咱们不过经过它实行一个大略的功效, 获得咱们体例中硬盘的关系消息. 咱们须要运用.net framwork内里system.management名字空间下供给的类来实行.using system;using system.management;using system.collections;using system.collections.specialized; namespace ace_console{ class ace_console { [stathread] static void main(string[] args) { stringcollection propnames = new stringcollection(); managementclass driveclass = new managementclass("win32_diskdrive"); propertydatacollection props = driveclass.properties; foreach (propertydata driveproperty in props) { propnames.add(driveproperty.name); } int idx = 0; managementobjectcollection drives = driveclass.getinstances(); foreach (managementobject drv in drives) { console.writeline(" drive({0}) properties ", idx+1); foreach (string strprop in propnames) { console.writeline("property: {0}, value: {1}", strprop, drv[strprop]); } } } }} .net framework sdk自带的扶助里有赢得论理硬盘巨细的代码:[c#]using system;using system.management; // this example demonstrates getting information about a class using the managementclass objectclass sample_managementclass{ public static int main(string[] args) { managementclass diskclass = new managementclass("win32_logicaldisk"); diskclass.get(); console.writeline("logical disk class has " + diskclass.properties.count + " properties"); return 0; }} [vb]imports systemimports system.management// this example demonstrates getting information about a class using the managementclass class sample_managementclassoverloads public shared function main(args() as string) as integerdim diskclass as new managementclass("win32_logicaldisk")diskclass.get()console.writeline(("logical disk class has " & diskclass.properties.count.tostring() & " properties"))return 0end functionend class

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.