-
Dec 10th, 2013, 01:03 PM
#1
Thread Starter
Hyperactive Member
Getting MAC Address from a MAC Client [VS2010] Silverlight
I've desperately scoured the internet for code on obtaining the MAC Addresss of a client, and the code I have found (2 functions below) works well for a Windows box, but
not for a MAC client.
Does anyone know of how I can get MAC address of a OSX or MAC client with Silverlight?
Code:
Declare Function SendARP Lib "iphlpapi.dll" (ByVal DestIP As UInt32, ByVal SrcIP As UInt32, ByVal pMacAddr As Byte(), ByRef PhyAddrLen As Integer) As Integer
Public Shared Function GetMAC(ByVal IPAddress As String) As String
Dim addr As Net.IPAddress = Net.IPAddress.Parse(IPAddress)
Dim mac() As Byte = New Byte(6) {}
Dim len As Integer = mac.Length
SendARP(CUInt(addr.Address), 0, mac, len)
Dim macAddress As String = BitConverter.ToString(mac, 0, len)
Return macAddress.Replace("-", "")
End Function
Public Shared Function GetMac() As String
Dim myResult As String = ""
Try
Using wmiLocator = Runtime.InteropServices.Automation.AutomationFactory.CreateObject("WbemScripting.SWbemLocator")
wmiLocator.Security_.ImpersonationLevel = 3
wmiLocator.Security_.AuthenticationLevel = 4
Dim wmiService = wmiLocator.ConnectServer(".", "root\cimv2")
Dim wmiQuery = "SELECT MACAddress FROM Win32_NetworkAdapterConfiguration where IPEnabled=true"
Dim queryResults = wmiService.ExecQuery(wmiQuery)
For Each o As Object In queryResults
myResult = o.MACAddress.ToString.Replace(":", "")
Exit For
Next
End Using
Catch ex As Exception
End Try
Return myResult
End Function
Truly, you have a dizzying intellect.
-
Dec 10th, 2013, 01:08 PM
#2
Re: Getting MAC Address from a MAC Client [VS2010] Silverlight
Sorry, but I really hope it's not possible...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|