
代码如下:
using System;using SystemDrawing;
using SystemWindowsForms;
using SystemManagement; //必须在项目中添加SystemManagement引用!
using SystemCollectionsGeneric;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
comboBox1DropDownStyle = ComboBoxStyleDropDownList;
comboBox1ItemsAddRange(GetNetcardName()ToArray());
}
// 获取计算机上安装的网卡名称
private List<string> GetNetcardName()
{
List<string> cardNames = new List<string>();
ManagementClass mc =
new ManagementClass("Win32_NetworkAdapter");
ManagementObjectCollection moc = mcGetInstances();
foreach (ManagementObject mo in moc)
{
cardNamesAdd(mo["Description"]ToString());
}
return cardNames;
}
}
}
@echo off & title 获取当前网络连接名 By 依梦琴瑶
for /f "tokens=3" %%a in ('netsh interface show interface ^| findstr "已连接"') do set "ConName=%%~b"
echo 当前正在上网的网络连接名是%ConName%
pause
Private Sub GetMyIP()
Dim strComputer As String
Dim objWMI As Object
Dim colIP As Object
Dim IP As Object
Dim I As Integer
strComputer = ""
Set objWMI = GetObject("winmgmts://" & strComputer & "/root/cimv2")
Set colIP = objWMIExecQuery _
("Select from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each IP In colIP
If Not IsNull(IPIPAddress) Then
For I = LBound(IPIPAddress) To UBound(IPIPAddress)
MsgBox "IP 地址:" & IPIPAddress(I) & Chr(10) & _
"网卡类型:" & IPDescription(I) & Chr(10) & _
"网卡地址:" & IPMacaddress(I)
Next
End If
Next
End Sub
Private Sub Command1_Click() '调用
GetMyIP
End Sub
以上就是关于c#获取网卡信息并且用combbox选择并显示出来全部的内容,包括:c#获取网卡信息并且用combbox选择并显示出来、批处理怎样查看当前正在用来上网网卡的网络连接的名称、高分求VB获取网卡列表等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)