http://expert.csdn.net/Expert/topic/1662/1662992.xml?temp=.2293512
解决方案 »
- 关于IEqualityComparer<T>,有没有简便的写法
- 急。ReportToolbar 跟 ReportViewer1 Devexpress
- 难!!!节能减排系统功能该如何设计?
- 请教高手。。。。
- 请问starter kit项目是啥东西?
- 50分求教如何向Excel中插入数据
- 根据ISO/IEC9945,1990怎样得到系统时间
- [三百里加急]子表的外键不更新???主表主键使用ID自动编号类型,高手们帮帮忙Access数据库
- 在IE11 下面 js window.showModalDialog返回值为undefined
- 想用C#做个单机版的window应用软件
- [讨论]C#数据库的设计问题
- 急救.....如何在listView1_SelectedIndexChanged事件中获得被中的索引值!!!
/// 得到网卡物理地址
/// </summary>
/// <returns>网卡物理地址列表</returns>
public string[] GetMacAddress()
{
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc = mc.GetInstances();
//****先得到网卡数目
int i = 0;
foreach(ManagementObject mo in moc)
{
if((bool)mo["IPEnabled"] == true)
{
i++;
}
mo.Dispose();
}
//***赋值给数组
ManagementClass mc_2 = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc_2 = mc_2.GetInstances();
string []array = new string[i];
int j = 0;
foreach(ManagementObject mo in moc_2)
{
if((bool)mo["IPEnabled"] == true)
{
string delcolon = mo["MacAddress"].ToString();
delcolon = delcolon.Replace(":","");
array[j] = delcolon;
j++;
}
mo.Dispose();
}
return array;
}