- 积分
- 40165
- 好友
- 记录
- 主题
- 帖子
- 听众
- 收听
|
发表于 2016-4-8 09:53:05
|
显示全部楼层
http://www.sufeinet.com/thread-2347-1-1.html
这里有获取设备的方法,
项目右键,添加对System.Management的引用
//using System.Management;
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection nics = mc.GetInstances();
foreach (ManagementObject nic in nics)
{
if (Convert.ToBoolean(nic["ipEnabled"]) == true)
{
MessageBox.Show((nic["IPAddress"] as String[])[0]);
MessageBox.Show((nic["IPSubnet"] as String[])[0]);
MessageBox.Show((nic["DefaultIPGateway"] as String[])[0]);
}
} |
|