VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "mac"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Public Function GetMACAddress(ip As String) As String

Dim tmp As String
Dim pASTAT As Long
Dim NCB As NET_CONTROL_BLOCK
Dim AST As ASTAT
NCB.ncb_command = NCBRESET
Call Netbios(NCB)
NCB.ncb_callname = ip
NCB.ncb_command = NCBASTAT
NCB.ncb_lana_num = 0
NCB.ncb_length = Len(AST)

pASTAT = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS _
Or HEAP_ZERO_MEMORY, NCB.ncb_length)

If pASTAT = 0 Then
Debug.Print "memory allocation failed!"
Exit Function
End If

NCB.ncb_buffer = pASTAT
Call Netbios(NCB)

CopyMemory AST, NCB.ncb_buffer, Len(AST)

tmp = Format$(Hex(AST.adapt.adapter_address(0)), "00") & " " & _
      Format$(Hex(AST.adapt.adapter_address(1)), "00") & " " & _
      Format$(Hex(AST.adapt.adapter_address(2)), "00") & " " & _
      Format$(Hex(AST.adapt.adapter_address(3)), "00") & " " & _
      Format$(Hex(AST.adapt.adapter_address(4)), "00") & " " & _
      Format$(Hex(AST.adapt.adapter_address(5)), "00")


HeapFree GetProcessHeap(), 0, pASTAT

GetMACAddress = tmp

End Function

