Imports System.Net.NetworkInformation
Function getMacAddress()
Dim nics() As NetworkInterface = _
NetworkInterface.GetAllNetworkInterfaces
Return nics(0).GetPhysicalAddress.ToString
End Function
System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces() 可取得所有 NIC 的 NetworkInterface
NetworkInterface.GetPhysicalAddress() 可取得 MAC
NetworkInterface.GetIPProperties() 可取得 IP
'NetworkInterface.GetPhysicalAddress() 回傳 PhysicalAddress 型態, 可以用
dim MacAdd as String= BitConver.ToString(NetworkInterface.GetPhysicalAddress().GetAddressBytes())
'NetworkInterface.GetIPProperties() 回傳 IPInterfaceProperties 型態, 可以用
dim prop as IPInterfaceProperties = NetworkInterface.GetIPProperties()
dim ip as string = prop.UnicastAddresses[0].Address.ToString()
沒有留言:
張貼留言