国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

使用WMI獲得硬盤的信息

2024-07-21 02:17:15
字體:
來源:轉載
供稿:網友
首先,什么是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 object

class 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 system

imports system.management



// this example demonstrates getting information about a class using the managementclass

class sample_managementclass


overloads public shared function main(args() as string) as integer

dim diskclass as new managementclass("win32_logicaldisk")

diskclass.get()

console.writeline(("logical disk class has " & diskclass.properties.count.tostring() & " properties"))

return 0

end function

end class

注冊會員,創建你的web開發資料庫,
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 宜春市| 麻栗坡县| 西林县| 万荣县| 漠河县| 济源市| 宜兴市| 泰兴市| 大荔县| 雅江县| 康平县| 镇雄县| 哈巴河县| 腾冲县| 汕尾市| 禄丰县| 潜江市| 巨野县| 商都县| 邮箱| 山西省| 永泰县| 旺苍县| 巴楚县| 太湖县| 巴塘县| 新龙县| 崇左市| 尼木县| 舒兰市| 玉龙| 自治县| 嵩明县| 通渭县| 三亚市| 嘉义市| 平谷区| 广平县| 五大连池市| 七台河市| 宜宾县|