Getting MAC Address from a MAC Client [VS2010] Silverlight-VBForums
Results 1 to 2 of 2

Thread: Getting MAC Address from a MAC Client [VS2010] Silverlight

  1. #1

    Thread Starter
    Hyperactive Member gtilles's Avatar
    Join Date
    Dec 2004
    Planet Earth

    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?

     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 = ""
                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
                End Using
            Catch ex As Exception
            End Try
            Return myResult
        End Function
    Truly, you have a dizzying intellect.

  2. #2
    Frenzied Member
    Join Date
    Oct 2013

    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


Click Here to Expand Forum to Full Width

Survey posted by VBForums.