十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
你可以使用WMI来获取MAC ID。。加上一些特定的条件也可以实现获取WLAN MAC_ID
成都创新互联致力于网站制作、做网站,成都网站设计,集团网站建设等服务标准化,推过标准化降低中小企业的建站的成本,并持续提升建站的定制化服务水平进行质量交付,让企业网站从市场竞争中脱颖而出。 选择成都创新互联,就选择了安全、稳定、美观的网站建设服务!
首先MAC地址在网卡中是固定的,可以修改,但通常不进行修改,通过vb.net修改的方式并不清楚但在XP或者W2000里面可以通过更改注册表进行修改
我找了一些C# 的VB。NET 貌似很少不过都是。NET 平台。你看看吧都应该通用的。
添加对System.Management的引用
using System.Management;
。。。
//获取IP,子网掩码(subnet mask)和默认网关
ManagementClass mc = new ManagementClass( "Win32_NetworkAdapterConfiguration ");
ManagementObjectCollection nics = mc.GetInstances();
foreach(ManagementObject nic in nics)
{
if(Convert.ToBoolean(nic[ "ipEnabled "]) == true)
{
Console.WriteLine((nic[ "IPAddress "] as String[])[0]);
Console.WriteLine((nic[ "IPSubnet "] as String[])[0]);
Console.WriteLine((nic[ "DefaultIPGateway "] as String[])[0]);
}
}
获取硬件信息源代码:
获取硬件信息演示程序:
汉化
利用using System.Management类来获取相应的硬件知识
其实这类东西很容易找到答案的,方法非常多,最常见的API模式,你去搜索吧,保证一把一把的
Public Function EnumNetworkAdapters() As String
Try
Dim query As System.Management.ManagementObjectSearcher = New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration")
Dim queryCollection As System.Management.ManagementObjectCollection = query.Get()
Dim mo As New System.Management.ManagementObject
For Each mo In queryCollection
If IsDBNull(mo.Item("Description")) = False Then
EnumNetworkAdapters = mo.Item("Description") "|||"
End If
If IsDBNull(mo.Item("macaddress")) = False Then
If mo.Item("macaddress") "" Then
EnumNetworkAdapters = mo.Item("macaddress") "|||"
End If
End If
If IsDBNull(mo.Item("IPAddress")) = False Then
Dim temp As String
temp = Join(mo.Item("IPAddress"), ".")
If temp "" Then
EnumNetworkAdapters = temp "|||"
End If
End If
Next
Catch err A* **ception
EnumNetworkAdapters = err.Message err.StackTrace
End Try
End Function
刚刚我自己写了一段 是引用System.net 来做的 我不喜欢用WMI 主要是查出来的信息不准确,下面我附上源码 希望可以加分给我
Imports System.Net
Imports System.Net.NetworkInformation
Public Class Form1
Private Sub btnGetMac_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetMac.Click
Dim NetworkInterfaces() As NetworkInterface
NetworkInterfaces = NetworkInterface.GetAllNetworkInterfaces()
If NetworkInterfaces.Length 0 Then
For Each NetWork In NetworkInterfaces
txtMac.Text = txtMac.Text +
"MAC地址:" + NetWork.GetPhysicalAddress().ToString() + Environment.NewLine +
"网络连接:" + NetWork.Name + Environment.NewLine +
"网卡序列号:" + NetWork.Id + Environment.NewLine +
"网络类型:" + NetWork.NetworkInterfaceType.ToString() + Environment.NewLine +
"网络速度:" + (NetWork.Speed / 1000000).ToString() + "MB" + Environment.NewLine
Next
End If
End Sub
End Class
Private Sub Form_Load()
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