用系统注册表找出安装在Windows NT /2000/XP系统中的网络设备,并显示每个设备的ip信息
2007-05-31 15:57
295 查看
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32;
namespace CardGrab
...{
class Program
...{
static void Main(string[] args)
...{
RegistryKey start = Registry.LocalMachine;
RegistryKey cardServiceName, networkKey;
string networkcardKey = "SoftWare/Microsoft/Windows NT/CurrentVersion/NetworkCards";
string serviceKey = "System/CurrentControlSet/Services/";
string networkcardKeyName, deviceName;
string deviceServiceName, serviceName;
RegistryKey serviceNames = start.OpenSubKey(networkcardKey);
if (serviceNames == null)
...{
Console.WriteLine("Bad registry key");
return;
}
string[] networkCards = serviceNames.GetSubKeyNames();
serviceNames.Close();
foreach (string keyName in networkCards)
...{
networkcardKeyName = networkcardKey + "/" + keyName;
cardServiceName = start.OpenSubKey(networkcardKeyName);
if (cardServiceName == null)
...{
Console.WriteLine("Bad registry key {0}", networkcardKeyName);
return;
}
deviceServiceName = (string)cardServiceName.GetValue("ServiceName");
deviceName = (string)cardServiceName.GetValue("Description");
Console.WriteLine(" NetWork card:{0}", deviceName);
serviceName = serviceKey + deviceServiceName + "/Parameters/Tcpip";
networkKey = start.OpenSubKey(serviceName);
if (networkKey == null)
...{
Console.WriteLine("No IP configuration set");
}
else
...{
string[] ipaddresses = (string[])networkKey.GetValue("IPAddress");
string[] defaltGateways = (string[])networkKey.GetValue("DefaultGateway");
string[] subnetmasks = (string[])networkKey.GetValue("SubnetMask");
foreach (string ipaddress in ipaddresses)
...{
Console.WriteLine(" IP Address:{0}", ipaddress);
}
foreach (string subnetmask in subnetmasks)
...{
Console.WriteLine(" Subnet Mask:{0}", subnetmask);
}
foreach (string defaltGateway in defaltGateways)
...{
Console.WriteLine(" Getway:{0}", defaltGateway);
}
networkKey.Close();
}
}
start.Close();
Console.Read();
}
}
}
相关文章推荐
- 安装Subclipse插件后,去除每个文件后面都显示版本信息的方法
- ifconfig显示网络设备信息(激活状态的)
- Linux-----系统安装【三】【配置ip等网络信息】
- 读取xml文件里switch节点的IP和设备信息,ping设备,异常显示在列表里
- 显示协议统计信息和当前 TCP/IP 网络连接。
- 显示协议统计信息和当前 TCP/IP 网络连接
- 解决RHEL6.5系统设置IP后,重启网络服务显示设备不存在问题
- NetFlow是一种数据交换方式,提供网络流量的会话级视图,记录下每个TCP/IP事务的信息
- 安装Centos7过程中网络和主机名:显示没有可用网络设备
- 初学python-获取网络设备配置文件接口IP信息
- Atitit 网络设备的自动发现机制 需求如下: 1、自动获取当前设备所在网段及当前与当前网段有连接的网段的所有IP,并判断出是哪类设备。如:服务器、交换机、防火墙等。 2、如何根据第1点得到的
- Bluetooth 4.2 让每个蓝牙装置都有能连上网络的 IP 门牌,物联网应用更加到位
- 获取android设备已安装应用信息
- WinPcap编程【3】获取已安装设备的高级信息
- 如何在cisco/h3c/华为的网络设备中一次性打印全部配置信息(show run和display current-configuration)
- 错误信息:通常每个套接字地址(协议/网络地址/端口)只允许使用一次.
- CentOS 6.8 新安装系统的网络IP配置(转载)
- 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:4.安装Oracle RAC FAQ-4.7.Oracle 11G R2 RAC修改public网络IP
- 计算机网络信息服务系统的安装与配置(一)
- Win10 Mobile预览版10549:显示连接移动热点设备的详细信息