>*!* typedef struct _IP_ADAPTER_ADDRESSES { >*!* union { >*!* ULONGLONG Alignment; 0:8 >*!* struct { >*!* ULONG Length; >*!* DWORD IfIndex; >*!* }; >*!* }; >*!* struct _IP_ADAPTER_ADDRESSES* Next; >*!* PCHAR AdapterName; >*!* PIP_ADAPTER_UNICAST_ADDRESS FirstUnicastAddress; >*!* PIP_ADAPTER_ANYCAST_ADDRESS FirstAnycastAddress; >*!* PIP_ADAPTER_MULTICAST_ADDRESS FirstMulticastAddress; >*!* PIP_ADAPTER_DNS_SERVER_ADDRESS FirstDnsServerAddress; >*!* PWCHAR DnsSuffix; >*!* PWCHAR Description; >*!* PWCHAR FriendlyName; >*!* BYTE PhysicalAddress[MAX_ADAPTER_ADDRESS_LENGTH]; >*!* DWORD PhysicalAddressLength; >*!* DWORD Flags; >*!* DWORD Mtu; >*!* DWORD IfType; >*!* IF_OPER_STATUS OperStatus; >*!* DWORD Ipv6IfIndex; >*!* DWORD ZoneIndices[16]; >*!* PIP_ADAPTER_PREFIX FirstPrefix; >*!* } IP_ADAPTER_ADDRESSES, *PIP_ADAPTER_ADDRESSES; >>
lcComputer = "." loWMIService = GetObject("winmgmts:\\" + lcComputer + "\root\cimv2") IPConfigSet = loWMIService.ExecQuery ; ("Select IPAddress from Win32_NetworkAdapterConfiguration") For Each IPConfig in IPConfigSet If !IsNull(IPConfig.IPAddress) ?"IP Address is:"+IPConfig.IPAddress(0) ? "Mac address is :"+IpToMacAddress(IPConfig.IPAddress(0)) endif next FUNCTION IpToMacAddress(lcIP) DECLARE INTEGER inet_addr IN ws2_32.dll STRING cIP DECLARE INTEGER SendARP IN iphlpapi.dll; INTEGER destIP, INTEGER sourceIP,; STRING @ pMacAddr, INTEGER @ PhyAddrLen LOCAL lnHr, lnIpAddr, lcMacAddr, lnLen lnIpAddr = inet_addr(lcIp) lcMacAddr = REPLICATE(CHR(0),6) lnLen = 6 lnHr = SendARP(lnIpAddr,0,@lcMacAddr,@lnLen) RETURN BinaryToMac(lcMacAddr,lnLen) ENDFUNC FUNCTION BinaryToMac(lcMacAddr, lnLen) LOCAL lcMac, xj lcMac = "" FOR xj = 1 TO lnLen - 1 lcMac = lcMac + RIGHT(TRANSFORM(ASC(; SUBSTR(lcMacAddr,xj,1)),"@0"),2) + ":" ENDFOR lcMac = lcMac + RIGHT(TRANSFORM(ASC(; SUBSTR(lcMacAddr,lnLen,1)),"@0"),2) RETURN lcMac ENDFUNC