快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

vb.net获取mac vbnet获取电脑信息

vb.net获取本地连接的mac地址

Private Sub Form_Load()

三原ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联公司的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18982081108(备注:SSL证书合作)期待与您的合作!

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 = objWMI.ExecQuery _

("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

For Each IP In colIP

If Not IsNull(IP.IPAddress) Then

For I = LBound(IP.IPAddress) To UBound(IP.IPAddress)

MsgBox "IP地址:" IP.IPAddress(I) Chr(10) _

"网卡类型:" IP.Description(I) Chr(10) _

"网卡地址:" IP.Macaddress(I)

Next

End If

Next

End Sub

怎么用vb.net获取无线网络的MAC地址

你可以使用WMI来获取MAC ID。。加上一些特定的条件也可以实现获取WLAN MAC_ID

用vb.net如何取得mac地址?

这是C#的,你可以转换一下

using System.Management;

//获取网卡的系列号

private static string GetMacAddress()

{

string ret = "";

try

{

ManagementClass cimobject = new ManagementClass("Win32_NetworkAdapterConfiguration");

ManagementObjectCollection moc = cimobject.GetInstances();

if (moc.Count == 0)

return "";

else

{

foreach (ManagementObject mo in moc)

{

if ((bool)mo["IPEnabled"] == true)

{

ret = (string)mo.Properties["MacAddress"].Value;

break;

}

}

}

}

catch

{

ret = "";

}

return ret;

}

用VB获取MAC地址

Private Sub Form_Load()

Dim Mac

strComputer = "."

Mac = ""

'获得MAC信息

Set objWMIService = GetObject("winmgmts:" "{impersonationLevel=impersonate}!//" strComputer "/root/cimv2")'''加上这个

Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")

For Each objItem In colItems

Mac = Mac + " " + objItem.macaddress

Next

TeMac.Text = Replace(Trim(Mac), ":", "-")

strComputer = "."

Set objWMI = GetObject("winmgmts://" strComputer "/root/cimv2")

Set colIP = objWMI.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

For Each Ip In colIP

If Not IsNull(Ip.ipaddress) Then

For i = LBound(Ip.ipaddress) To UBound(Ip.ipaddress)

'Mac = Ip.macaddress(I)objObject.DNSHostName

If Ip.ipaddress(i) = "0.0.0.0" Then

Else

TeIp.Text = Trim(TeIp.Text + " " + Ip.ipaddress(i))

End If

'MsgBox "IP 地址:" IP.ipaddress(I) Chr(10) _

"网卡类型:" IP.Description(I) Chr(10) _

"网卡地址:" IP.macaddress(I)

Next

End If

Next

End Sub


分享文章:vb.net获取mac vbnet获取电脑信息
标题路径:http://6mz.cn/article/ddcchoh.html

其他资讯