Quote Originally Posted by ivansc View Post
Hi Pepe,
maybe this help
Code:
Use Windows.pkg
Use Dll.pkg
type WKSTA_TRANSPORT_INFO
  Field WKSTA_TRANSPORT_INFO.wkti0_quality_of_service  as DWord   
  Field WKSTA_TRANSPORT_INFO.wkti0_number_of_vcs       as DWord   
  Field WKSTA_TRANSPORT_INFO.wkti0_transport_name      as Pointer 
  Field WKSTA_TRANSPORT_INFO.wkti0_transport_address   as Pointer 
  Field WKSTA_TRANSPORT_INFO.wkti0_wan_ish             as Boolean 
End_type
Define NERR_Success for 0
Define NERR_BASE for 2100
Define ERROR_MORE_DATA for 234 //More entries are available. Specify a large enough buffer to receive all entries.
Define ERROR_INVALID_LEVEL for 124 //The level parameter, which indicates what level of data structure information is available, is invalid. This Error is returned If the level parameter is specified as a value other than zero.
Define ERROR_INVALID_PARAMETER for 87 //One or more parameters was invalid. This Error is returned If the bufptr or the entriesread parameters are NULL pointers.
Define ERROR_NOT_ENOUGH_MEMORY for 8 //Insufficient memory was available to process the request.
Define ERROR_NOT_SUPPORTED for 50 //The request is not supported. This Error is returned If a remote server was specified in servername parameter, and this request is not supported on the remote server.
Define NERR_BufTooSmall for (NERR_BASE+23) //More entries are available. Specify a large enough buffer to receive all entries. This Error code is defined in the Lmerr.h header file.
Define ERROR_ACCESS_DENIED for 5 //Access is denied. 
External_Function NetWkstaTransportEnum "NetWkstaTransportEnum" Netapi32.dll ;
    Pointer servername DWord level Pointer bufptr DWord prefmaxlen ; 
    Pointer entriesread Pointer totalentries DWord resumehandle ;
    Returns Integer
External_Function NetApiBufferFree "NetApiBufferFree" Netapi32.dll ;
    Pointer Buffer Returns Integer
Function GetMacAddress Global String ServerName Returns String[]
    String  sWKSTA_TRANSPORT_INFO sWKSTA_TRANSPORT_INFO_0 
    Pointer pBuffer pBuffer0 pWKSTA_TRANSPORT_INFO_0
    DWord prefmaxlen entriesread totalentries resumehandle level
    Integer iwkti0_quality_of_service iwkti0_number_of_vcs iwkti0_transport_name iwkti0_transport_address
    Boolean bwkti0_wan_ish
    Integer ierror i j k
    String widechar s1 stransport_name stransport_address
    String[] sMac
    Move 0 to level
    Move 0 to entriesread
    Move 0 to totalentries
    Move 0 to resumehandle
    Move 0 to pWKSTA_TRANSPORT_INFO_0
    Move (WKSTA_TRANSPORT_INFO_size*50) to prefmaxlen
    Move (AddressOf(pWKSTA_TRANSPORT_INFO_0)) to pBuffer
    If (Left(ServerName,2)<>"\\") Move ("\\"+ServerName) to ServerName
    Move "" to widechar
    For i from 1 to 129
       If (i>Length(ServerName)) Append widechar (Character(0)+Character(0))
       Else  Append widechar (Mid(ServerName,1,i)+Character(0))
    Loop
    Move (AddressOf(widechar)) to pBuffer0
    Move (NetWkstaTransportEnum(pBuffer0,level,pBuffer,prefmaxlen,AddressOf(entriesread),AddressOf(totalentries),resumehandle)) to ierror
    If ierror Begin
       Showln "error en acceso ... " ierror
       If pWKSTA_TRANSPORT_INFO_0 Move (NetApiBufferFree(pWKSTA_TRANSPORT_INFO_0)) to ierror
       Function_Return sMac
    End
    ZeroString prefmaxlen to sWKSTA_TRANSPORT_INFO_0
    Move (MemCopy(AddressOf(sWKSTA_TRANSPORT_INFO_0),pWKSTA_TRANSPORT_INFO_0,prefmaxlen)) to j
    For i from 1 to entriesread
       Move (Mid(sWKSTA_TRANSPORT_INFO_0,WKSTA_TRANSPORT_INFO_size,i-1*WKSTA_TRANSPORT_INFO_size+1)) to sWKSTA_TRANSPORT_INFO
       GetBuff from sWKSTA_TRANSPORT_INFO At WKSTA_TRANSPORT_INFO.wkti0_quality_of_service to iwkti0_quality_of_service
       GetBuff from sWKSTA_TRANSPORT_INFO At WKSTA_TRANSPORT_INFO.wkti0_number_of_vcs to iwkti0_number_of_vcs
       GetBuff from sWKSTA_TRANSPORT_INFO At WKSTA_TRANSPORT_INFO.wkti0_transport_name to iwkti0_transport_name
       GetBuff from sWKSTA_TRANSPORT_INFO At WKSTA_TRANSPORT_INFO.wkti0_transport_address to iwkti0_transport_address
       GetBuff from sWKSTA_TRANSPORT_INFO At WKSTA_TRANSPORT_INFO.wkti0_wan_ish to bwkti0_wan_ish
       Move " " to s1  
       Move "" to stransport_name
       For j from iwkti0_transport_name to (iwkti0_transport_name+256)
          Move (MemCopy(AddressOf(s1),j,1)) to k
          If (s1<>Character(0)) Append stransport_name s1
          Else Move (iwkti0_transport_name+256) to j
          Increment j
       Loop
       Move "" to stransport_address
       For j from iwkti0_transport_address to (iwkti0_transport_address+256)
          Move (MemCopy(AddressOf(s1),j,1)) to k
          If (s1<>Character(0)) Append stransport_address s1
          Else Move (iwkti0_transport_address+256) to j
          Increment j
       Loop
       Show iwkti0_quality_of_service "  "
       Show iwkti0_number_of_vcs "  "
       Show iwkti0_transport_name "  "
       Show iwkti0_transport_address "  "
       Show bwkti0_wan_ish "  "
       Showln stransport_name "  " stransport_address
       If (Pos("TCPIP",Uppercase(stransport_name))) Move stransport_address to sMac[SizeOfArray(sMac)]
    Loop
    If pWKSTA_TRANSPORT_INFO_0 Move (NetApiBufferFree(pWKSTA_TRANSPORT_INFO_0)) to ierror
    Function_Return sMac
End_Function
Procedure domac
   String [] sMac
   Integer I
   Move (GetMacAddress("localhost")) to sMac
   For I from 0 to (SizeOfArray(sMac)-1)
      Send Info_Box ("Mac "+String(I+1)+" : "+sMac[I]) 
   Loop
End_Procedure
Send domac
regards
Ivan
My device has two MAC Addresses, but this code return just one.