Reputation: 11
How do I find the IP Address for a mac id in WindowsCE using VB.net Smartdevice application in VS 2008/ VS2005?
I am trying to use OpenNETCF.Net but I am not getting the desired results.
Does anyone know this? Please post your suggestions.
Upvotes: 1
Views: 1614
Reputation: 67188
You say you tried using the OpenNETCF.Net.dll assembly, but you didn't say what you tried. In C# it would look something like this:
IPAddress GetAdapterForMac(PhysicalAddress mac)
{
var intf = (from n in NetworkInterface.GetAllNetworkInterfaces()
where n.GetPhysicalAddress().Equals(mac)
select n).FirstOrDefault();
if (intf == null) return null;
return intf.CurrentIpAddress;
}
My VB.NET is rusty, but I think that translates to something like this:
Imports System.Linq
Imports OpenNETCF.Net.NetworkInformation
Private Function GetAdapterForMac(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
Return Nothing
End If
Return intf.CurrentIpAddress
End Function
Upvotes: 3