InPowerS.Net

 找回密碼
 註冊
搜索
查看: 4668|回復: 0

VB.NET 抓IP 和 MacAddress

[複製鏈接]
發表於 2008-12-29 17:37:50 | 顯示全部樓層 |閱讀模式
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()
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

小黑屋|Archiver|手機版|InPowerS.Net

GMT+8, 2024-3-29 10:04

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回復 返回頂部 返回列表