Using Win32 functions in Visual FoxPro Image Gallery
IP Helper
..msdn
GetAdaptersAddresses
GetAdaptersInfo
GetBestInterface
GetBestRoute
GetIfEntry
GetInterfaceInfo
GetIpAddrTable
GetIpNetTable
GetIpStatistics
GetNetworkParams
GetNumberOfInterfaces
GetRTTAndHopCount
GetTcp6Table
GetTcpStatistics
GetTcpTable
GetUdpTable
IcmpCloseHandle
IcmpCreateFile
IcmpSendEcho
if_indextoname
if_nametoindex
IpReleaseAddress
IpRenewAddress
SendARP
Code examples:
Obtaining MAC address through Address Resolution Protocol (ARP) request
SendARP
..msdn    Add comment     W32 Constants      Translate this page
Sends an ARP request to obtain the physical address that corresponds to the specified destination IP address.
Code examples:
Obtaining MAC address through Address Resolution Protocol (ARP) request
Declaration:
DWORD SendARP(
  IPAddr DestIP,
  IPAddr SrcIP,
  PULONG pMacAddr,
  PULONG PhyAddrLen
);

FoxPro declaration:
DECLARE INTEGER SendARP IN iphlpapi;
    INTEGER destIP,;
    INTEGER sourceIP,;
    STRING @pMacAddr,;
    INTEGER @PhyAddrLen

Parameters:
DestIP
[in] Destination IP address, in the form of an IPAddr structure.

SrcIP
[in] IP address of the sender, in the form of an IPAddr structure.

pMacAddr
[out] Pointer to an array of ULONG variables.

PhyAddrLen
[in, out] On input, specifies the maximum buffer size the user has set aside at pMacAddr to receive the MAC address, in bytes. On output, specifies the number of bytes written to pMacAddr.
Return value:
If the function succeeds, the return value is NO_ERROR (0).
My comment:
The ARP (Address Resolution Protocol) request attempts to obtain the physical address (MAC address) that corresponds to this IP address.

* * *
Dynamic Host Configuration Protocol (DHCP) FAQ

Christian Ehlscheid offered this code on UniversalThread as a solution for obtaining physical address for a given ip address:

? IpToMacAddress("192.168.1.0")

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


The Address Resolution Protocol (ARP) is a protocol used by the Internet Protocol (IP) [RFC826], specifically IPv4, to map IP network addresses to the hardware addresses used by a data link protocol.
Word Index links for the SendARP :
Translate this page:
  Spanish    Portuguese    German    French    Italian  
FreeTranslation.com offers instant, free translations of text or web pages.
Created: 2006-02-24 08:38:52
Modified: 2006-07-07 09:52:37
Visited in last 7 days: 46
User Contributed Notes:
There are no notes on this subject.


Copyright 2001-2017 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

Privacy policy
Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.6.38), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (54.82.112.193)
17 sec.Function: 'PeekMessage'
35 sec.Function: 'GetProcessVersion'
51 sec.Function: 'CreateMenu'
1.13 min.Function: 'IsWindow'
1.4 min.Function: 'WTSUnRegisterSessionNotification'
1.7 min.Function: 'ShowCursor'
1.97 min.Function: 'NetShareAdd'
2.27 min.Function: 'GetUserGeoID'
2.53 min.Function: 'GetMenuItemInfo'
2.83 min.Function: 'WritePrivateProfileString'
Google
Advertise here!