【发布时间】:2009-11-14 22:05:21
【问题描述】:
【问题讨论】:
【问题讨论】:
又快又脏:
foreach(ManagementObject objMO in objMOC)
{
if(!(bool)objMO["ipEnabled"])
continue;
if(!string.Equals(objMO["MACAddress"], "00:ff:xx:xx:xx:xx"))
continue;
// change settings
break;
}
【讨论】:
WMI 的一个大问题通常是,如果对象/属性是只读的或可更新的,则您不容易找到信息。
但是一般的方法——对于你上面的循环——是这样的:
objMO["PropertyName"] = "newValue"; //但可能是以下(我很少这样做): //objMO["PropertyName"].Value = "newValue"; objMO.Put(); //那个!当然,使用正确的数据类型。
试试吧,希望对你有帮助!
br--马布拉
【讨论】: