重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
Private Sub Form_Load()
十多年的蕉城网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。成都营销网站建设的优势是能够根据用户设备显示端的尺寸不同,自动调整蕉城建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。成都创新互联从事“蕉城网站设计”,“蕉城网站推广”以来,每个客户项目都认真落实执行。
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
你可以使用WMI来获取MAC ID。。加上一些特定的条件也可以实现获取WLAN MAC_ID
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
首先MAC地址在网卡中是固定的,可以修改,但通常不进行修改,通过vb.net修改的方式并不清楚但在XP或者W2000里面可以通过更改注册表进行修改
刚刚我自己写了一段 是引用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
我找了一些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模式,你去搜索吧,保证一把一把的