Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <DllImport("iphlpapi.dll", SetLastError:=True)> _
- Public Shared Function GetAdaptersInfo(ByVal info As Byte(), ByRef size As UInteger) As Integer
- End Function
- Public Shared Function GetMacAddress() As String
- Dim num As UInteger = 0UI
- GetAdaptersInfo(Nothing, num)
- Dim array As Byte() = New Byte(CInt(num) - 1) {}
- Dim adaptersInfo As Integer = GetAdaptersInfo(array, num)
- If adaptersInfo = 0 Then
- Dim macAddress As String = ""
- Dim macLength As Integer = BitConverter.ToInt32(array, 400)
- macAddress = BitConverter.ToString(array, 404, macLength)
- macAddress = macAddress.Replace("-", ":")
- Return macAddress
- Else
- Return ""
- End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement