If you use the VFP2C32.FLL, it has a wrapper around ping that returns
results into an array.
SET LIBRARY TO vfp2c32.fll
?ICMPPING([aResults],[google.com],30,0,1000,32,.f.,4)
--
rk
-----Original Message-----
From: ProfoxTech [mailto:[email protected]] On Behalf Of
Jack Skelley
Sent: Wednesday, March 12, 2014 9:17 AM
To: [email protected]
Subject: RE: Do i have internet
Good Morning All;
The following is what I use to get all the active adapters in a box
and is used in conjunction with another app that returns very detailed
info about the adapters active or not. It is much neater (humbly I
say...) than ipconfig /all I hope it is useful!
Best regards,
Jack Skelley
DO declare_dll
SET SAFETY OFF
#DEFINE MIB_IPADDRROW_SIZE 24
PRIVATE lWinsockEnabled
lWinsockEnabled = InitWinsock()
LOCAL lcBuffer, lnBufsize, lnEntries, lnIndex, lcEntryBuf
* allocate a space large enough to keep the data lnBufsize = 8192
lcBuffer = Repli(Chr(0), lnBufsize) = GetIpAddrTable (@lcBuffer,
@lnBufsize, 1) lnEntries = buf2dword(SUBSTR(lcBuffer, 1,4))
* resulting cursor
CREATE CURSOR tAdapters (ipaddr C(15), iindex N(3), smask C(15), bcast
C(15), rsize N(12), hostname C(50)) FOR lnIndex = 1 TO lnEntries
lcEntryBuf = SUBSTR(lcBuffer, 5+(lnIndex-1)*MIB_IPADDRROW_SIZE,
MIB_IPADDRROW_SIZE)
= AddEntry (lcEntryBuf)
ENDFOR
IF lWinsockEnabled
= WSACleanup()
ENDIF
release dlls all
RETURN
*GO TOP
*BROWSE
* end of main
PROCEDURE AddEntry (lcEntryBuf)
LOCAL lcIPAddrBuf, lcIPAddr, lcHostName, lnIndex,;
lcMask, lcBCast, lnRSize
* IP address and the host name
lcIPAddrBuf = SUBSTR(lcEntryBuf, 1,4)
lcIPAddr = inet_ntoa(buf2dword(lcIPAddrBuf))
lcHostName = GetHostName(lcIPAddrBuf)
* the index of the interface associated with this IP address
lnIndex = buf2dword(SUBSTR(lcEntryBuf, 5,4))
* the subnet mask for the IP address
lcMask = inet_ntoa(buf2dword(SUBSTR(lcEntryBuf, 9,4)))
* the broadcast address
lcBCast = inet_ntoa(buf2dword(SUBSTR(lcEntryBuf, 13,4)))
* the maximum re-assembly size for received datagrams
lnRSize = buf2dword(SUBSTR(lcEntryBuf, 17,4))
* VT Mod: Discard 127.0.0.1 and 0.0.0.0
IF lcIPAddr <>"127.0.0.1" .AND. lcIPAddr <> "0.0.0.0"
INSERT INTO tAdapters VALUES (lcIPAddr, lnIndex, lcMask,
lcBCast, lnRSize, lcHostName)
ENDIF
RETURN
FUNCTION GetHostName (lcAddrBuf)
#DEFINE AF_INET 2 && internetwork: UDP, TCP, etc.
#DEFINE HOSTENT_SIZE 16
LOCAL lcResult, lnHOSTENTptr, lcHOSTENT
lcResult = ""
IF lWinsockEnabled
lnHOSTENTptr = gethostbyaddr(lcAddrBuf, 4, AF_INET)
IF lnHOSTENTptr <> 0
lcHOSTENT = GetMemBuf (lnHOSTENTptr, HOSTENT_SIZE)
lcResult = GetMemStr(buf2dword(SUBSTR(lcHOSTENT, 1,4)))
ENDIF
ENDIF
RETURN lcResult
FUNCTION InitWinsock()
* Initializing the Winsock service for the application #DEFINE
WSADATA_SIZE 398
#DEFINE WS_VERSION 514 && 0x0202
LOCAL lcWSADATAln, lnInitResult
lcWSADATA = Repli(Chr(0), WSADATA_SIZE)
lnInitResult = WSAStartup (WS_VERSION, @lcWSADATA) RETURN
(lnInitResult = 0) FUNCTION GetMemBuf (lnAddr, lnBufsize)
* returning data from a memory block
LOCAL lcBuffer
lcBuffer = Repli(Chr(0), lnBufsize)
= Heap2Str (@lcBuffer, lnAddr, lnBufsize) RETURN lcBuffer
FUNCTION GetMemStr (lnAddr)
* returning data from a memory block
* before the first occurence of a zero byte
LOCAL lcBuffer
lcBuffer = GetMemBuf (lnAddr, 250)
RETURN SUBSTR(lcBuffer, 1, AT(Chr(0),lcBuffer)-1) FUNCTION buf2dword
(lcBuffer) RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
Asc(SUBSTR(lcBuffer, 2,1)) * 256 +;
Asc(SUBSTR(lcBuffer, 3,1)) * 65536 +;
Asc(SUBSTR(lcBuffer, 4,1)) * 16777216 PROCEDURE declare_dll
DECLARE STRING inet_ntoa IN ws2_32 INTEGER in_addr
DECLARE INTEGER WSACleanup IN ws2_32
DECLARE INTEGER WSAStartup IN ws2_32 INTEGER wVerRq, STRING
@lpWSAData
DECLARE INTEGER gethostbyaddr IN ws2_32 STRING addr, INTEGER len,
INTEGER type
DECLARE RtlMoveMemory IN kernel32 As Heap2Str STRING @Dest,
INTEGER Src, INTEGER nLength
DECLARE INTEGER GetIpAddrTable IN iphlpapi STRING @pIpAddrTable,
INTEGER @pdwSize, INTEGER bOrder return
Jack Skelley
Senior Director, Programming/Computer Operations New Jersey Devils
(973)757-6164
[email protected]