Results 1 to 1 of 1

Thread: Get Mac Adress

  1. #1
    The_USDL
    The_USDL is offline
    Senior Member The_USDL's Avatar
    Join Date
    2011 Oct
    Posts
    201
    Thanks Thanks Given 
    24
    Thanks Thanks Received 
    538
    Thanked in
    47 Posts
    Rep Power
    0

    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!

  2. The Following User Says Thank You to The_USDL For This Useful Post:


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •