Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
show error for multiple set of MAC address i create a project here check the mac address process if match then run application else close the application

but some time show 061EA6B401C8 this mac address some time D0BF9C07C7EA
some time others please help me i have a idea MAC address is fix but now change my knowledge
i use this function :

What I have tried:

Public Function getMacAddress()
       Try
           Dim adapters As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
           Dim adapter As NetworkInterface
           Dim myMac As String = String.Empty

           For Each adapter In adapters
               Select Case adapter.NetworkInterfaceType
                   'Exclude Tunnels, Loopbacks and PPP
                   Case NetworkInterfaceType.Tunnel, NetworkInterfaceType.Loopback, NetworkInterfaceType.Ppp
                   Case Else
                       If Not adapter.GetPhysicalAddress.ToString = String.Empty And Not adapter.GetPhysicalAddress.ToString = "00000000000000E0" Then
                           myMac = adapter.GetPhysicalAddress.ToString
                           Exit For ' Got a mac so exit for
                       End If

               End Select
           Next adapter

           Return myMac
       Catch ex As Exception
           Return String.Empty
       End Try

   End Function
Posted
Updated 6-Nov-18 8:04am
v2

1 solution

Using MAC addressed for security purposes is not a good idea: they aren't unique, just unique on a particular segment and are very easily spoofed.

Plus, you aren't fetching the MAC address for the network adapter in that machine! See here: Retrieving IP and MAC addresses for a LAN[^] - there is a method in there to get the current PC MAC (it's in C#, but it's pretty obvious code).

But it won't work well as a security measure!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900