肥龍 發表於 2008-12-29 17:37:50

VB.NET 抓IP 和 MacAddress

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.Address.ToString()
頁: [1]
查看完整版本: VB.NET 抓IP 和 MacAddress