我有将 Mac 地址获取到 IPAddress 的示例代码,我正在尝试调用该函数,但我没有得到。
我有 Mac 地址
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim macadd As String = "00:19:70:7a:78:e0"
'' HOW DO I CONVERT STRING VALUE TO PHYSICALADDRESS OBJECT, because Physical.Parse i not available
''MsgBox(GetAdapterForMac(macaddress)) '' I want to Pass mac address here
End Sub
Private Function GetAdapterForMac(ByVal mac As PhysicalAddress) As IPAddress
Dim intf As NetworkInterface = (From n In NetworkInterface.GetAllNetworkInterfaces() _
Where n.GetPhysicalAddress().Equals(mac) _
Select n).FirstOrDefault()
If intf Is Nothing Then
Return Nothing
End If
Return intf.CurrentIpAddress()
End Function
谢谢