Advertisement
Guest User

Untitled

a guest
Jun 30th, 2015
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. <DllImport("iphlpapi.dll", SetLastError:=True)> _
  2. Public Shared Function GetAdaptersInfo(ByVal info As Byte(), ByRef size As UInteger) As Integer
  3. End Function
  4.  
  5. Public Shared Function GetMacAddress() As String
  6. Dim num As UInteger = 0UI
  7. GetAdaptersInfo(Nothing, num)
  8. Dim array As Byte() = New Byte(CInt(num) - 1) {}
  9. Dim adaptersInfo As Integer = GetAdaptersInfo(array, num)
  10. If adaptersInfo = 0 Then
  11. Dim macAddress As String = ""
  12. Dim macLength As Integer = BitConverter.ToInt32(array, 400)
  13. macAddress = BitConverter.ToString(array, 404, macLength)
  14. macAddress = macAddress.Replace("-", ":")
  15.  
  16. Return macAddress
  17. Else
  18. Return ""
  19. End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement