VB.NET获取⽹卡MAC地址的函数
注:⽹卡的MAC地址是可以在注册表中进⾏修改的;也可以在⽹卡的属性中进⾏修改。
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
enum函数EnumNetworkAdapters &= temp & "|||"
End If
End If
Next
Catch err A* **ception
EnumNetworkAdapters = err.Message & err.StackTrace
End Try
End Function
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论