An article "A New Way to Ping" published on CodeGuru pages by Bill Nolde is a source for this example, which is a direct C++ to VFP translation.
Another example shows how to convert a host name (like "www.myhost.com", "microsoft.com", "aol.com" etc.) to IP address in dotted format (like 192.168.0.1).
See also:
- How to ping a remote site using ICMP API calls
- How to retrieve adapter information for the local computer (including MAC address)
- Obtaining addresses for the adapters on the local computer (Win XP/2003/Vista)
- Using NetWkstaTransportEnum to obtain MAC Address of remote server
DO declare
LOCAL nDst, nHop, nRTT
nDst = inet_addr("212.58.244.67") && bbc news
STORE 0 TO nHop, nRTT
IF GetRTTAndHopCount(nDst, @nHop, 50, @nRTT) <> 0
? "Hop count to the destination:", nHop
? "Round-trip time, in milliseconds:", nRTT
ELSE
* on error, GetLastError may still return zero
? "Error"
ENDIF
* end of main
PROCEDURE declare
DECLARE INTEGER GetRTTAndHopCount IN Iphlpapi;
INTEGER DestIpAddress, LONG @HopCount,;
INTEGER MaxHops, LONG @RTT
DECLARE INTEGER inet_addr IN ws2_32 STRING cp
Home