-
Get Mac Adress
Code:
Option Explicit
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal numbytes As Long)
Private Declare Function GetAdaptersInfo Lib "iphlpapi.dll" (ByRef pAdapterInfo As Any, ByRef pOutlLenght As Long) As Long
Public Function MacAddress() As String
Dim bBuf() As Byte
Dim bMAC(7) As Byte
Dim lSecond As Long
Dim lType As Long
Dim lLenght As Long
Dim i As Long
Dim str As String
Call GetAdaptersInfo(0&, lLenght)
ReDim bBuf(0 To lLenght - 1) As Byte
Call GetAdaptersInfo(bBuf(0), lLenght)
CopyMemory lSecond, ByVal VarPtr(bBuf(0)), 4
CopyMemory lType, ByVal lSecond + &H1A0, &H4
CopyMemory bMAC(0), ByVal lSecond + &H194, &H8
If (lType = 6) Then
For i = 0 To 5
If Len(Hex(bMAC(i))) = 1 Then
MacAddress = MacAddress & "0" & Hex(bMAC(i))
Else
MacAddress = MacAddress & Hex(bMAC(i))
End If
If i < 5 Then MacAddress = MacAddress & "-"
Next i
End If
End Function
Like it? Click in Thanks!