本文介绍了C#Framework 3,5 WMI网络的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨.我如何获取所有信息.从我计算机的网卡中,我有3个卡可以连接,并且想使用WMI. Ex ip,mac,网关ip ...
最好的问候.
Hi. How do i get all info. from the network cards in my computer, I have 3 cards to connections and want to use WMI. Ex ip, mac, gateway ip...
Best Regards.
推荐答案
ManagementObjectSearcher m1 = new ManagementObjectSearcher("select * from Win32_NetworkAdapter");
foreach (ManagementObject mo in m1.Get())
{
Console.WriteLine("---------------------------------------------");
foreach (PropertyData property in mo.Properties)
{
try
{
string parameter = property.Name;
object value = mo[parameter];
Console.WriteLine(String.Format("{0} = {1}", parameter, value));
}
catch
{
Console.WriteLine("Couldn't get {0}", property.Name);
}
}
}
此代码段要求引用System.Management.dll
,您应该能够指定要从该查询中删除的任何内容.
希望这会有所帮助,
弗雷德里克·博纳德(Fredrik Bornander)
This snippet requires the System.Management.dll
to be referenced, you should be able to specify anything that you''d like to get out of that query.
Hope this helps,
Fredrik Bornander
这篇关于C#Framework 3,5 WMI网络的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!