解决方案 »
- 请教查看MSDN的方法
- 自定义performanceCounter获取指定进程的性能参数
- 正则表达式:如何在一个多行的字符串中匹配以字符 ' 开始,以 ! 结束的所有字符串?
- 用DataGridView绑定数据集数据后,如何获取当前选中的数据?
- 急!急!急!请教高手,程序非正常运行问题
- 高分提问关于treeview
- 代码已收到 weilysunhg进来接分
- 100求助,一个关于DataTable的问题
- SharpDevelop源码讨论区
- 我的OS是windows2003 iis6.0在用vs.net(2002)打开其中的示例时(Duwamish)时报错:“无法打开Web项目,文件路径与URL不符。这两者需要
- dropdownlist绑定数据后如何能将显示置空
- 查询SQL Server表数据,使用不同的方法返回结果集。
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Service\Tcpip\Parameters\Interfaces\
这个底下根据你网卡的数量会有不同的子项类似于{307A0543-1269-4429-9C09-E104F08C5B59}这种GUID值,
你遍历一下就可以了。
IPAddress--IP
DefaultGateway--网关
SubnetMask--掩码
string[] str = (String[])reg.GetValue("Route");
string asd = str[6].Substring(1, str[0].Length - 2);//此处的6是我的有线网卡
string path=@"System\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\"+asd;
RegistryKey reglp = Registry.LocalMachine.OpenSubKey(path);
string []strip = (string[])reglp.GetValue("IPAddress", "NULL", RegistryValueOptions.None);
//string[] strip=(string[])reglp.GetValue("IPAddress");
this.label1.Text = strip[0];
但是我想通过Software\Microsoft\Windows NT\CurrentVersion\NetworkCards下属的各个键值来读取各网卡的信息(这样可以有效的屏蔽很多虚拟网卡)
RegistryKey reg = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows NT\CurrentVersion\NetworkCards\8");
string str = (String)reg.GetValue("ServiceName");
string asd = str.Substring(1, str.Length - 2);
string path=@"System\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\"+"{"+asd+"}";
RegistryKey reglp = Registry.LocalMachine.OpenSubKey(path);
string []strip = (string[])reglp.GetValue("IPAddress", "NULL", RegistryValueOptions.None);
this.label1.Text = strip[0];
但是在Software\Microsoft\Windows NT\CurrentVersion\NetworkCards有两个树枝“8”,“12”,但是我又发现我同学的电脑里面是“8”,“13”,两台电脑都有两个网卡 而且两个网卡的厂家不一样,我该如何获得我指定网卡的IP地址呢?