- Code: Select all Expand view
- Function Ping(DestinationAddress) // String in IPv4 Format (192.168.0.1)
local IcmpHandle,Replicas
local nAddress := 0 // Numeric IPv4 after inet_addr()
local RequestData:="Test ping",;
RequestSize:=15,;
RequestOptions:="",;
ReplyBuffer:=space(278),;
ReplySize:=278,;
Timeout:=500 // Milliseconds
DestinationAddress:=left(alltrim(DestinationAddress)+space(15),15)
olbx:Add("DestinationAddress="+DestinationAddress)
olbx:REFRESH()
nAddress := inet_addr(DestinationAddress)
olbx:Add("nAddress="+Str(nAddress))
olbx:REFRESH()
IcmpHandle:=IcmpCreateFile()
olbx:Add("IcmpHandle="+Str(IcmpHandle))
olbx:REFRESH()
Replicas:=IcmpSendEcho(IcmpHandle,; // Application Hangs Here
nAddress,;
RequestData,;
RequestSize,;
0,;
ReplyBuffer,;
ReplySize,;
Timeout)
olbx:Add("Replicas="+Str(Replicas))
olbx:REFRESH()
IcmpCloseHandle(IcmpHandle)
return Replicas
DLL32 FUNCTION WSAGetLastError() AS _INT PASCAL FROM "WSAGetLastError" LIB "ws2_32.dll"
DLL32 FUNCTION inet_addr(cIP AS STRING) AS LONG PASCAL FROM "inet_addr" LIB "ws2_32.dll"
//DLL32 FUNCTION IcmpCreateFile() AS LONG PASCAL FROM "IcmpCreateFile" LIB "icmp.dll"
//DLL32 FUNCTION IcmpCloseHandle(IcmpHandle AS LONG) AS LONG PASCAL FROM "IcmpCloseHandle" LIB "icmp.dll"
//DLL32 FUNCTION IcmpSendEcho(IcmpHandle AS LONG,;
// DestinationAddress AS LONG,;
// RequestData AS STRING,;
// RequestSize AS LONG,;
// RequestOptions AS LONG,;
// ReplyBuffer AS LPSTR,;
// ReplySize AS LONG,;
// Timeout AS LONG) AS LONG PASCAL FROM "IcmpSendEcho" LIB "icmp.dll"
DLL32 FUNCTION IcmpCreateFile() AS LONG PASCAL FROM "IcmpCreateFile" LIB "iphlpapi.dll"
DLL32 FUNCTION IcmpCloseHandle(IcmpHandle AS LONG) AS LONG PASCAL FROM "IcmpCloseHandle" LIB "iphlpapi.dll"
DLL32 FUNCTION IcmpSendEcho(IcmpHandle AS LONG,;
DestinationAddress AS LONG,;
RequestData AS STRING,;
RequestSize AS LONG,;
RequestOptions AS LONG,;
ReplyBuffer AS LPSTR,;
ReplySize AS LONG,;
Timeout AS LONG) AS LONG PASCAL FROM "IcmpSendEcho" LIB "iphlpapi.dll"
The XP Results are:
DestinationAddress = 10.10.1.254
nAddress = -33486326
IcmpHandle = 1880
Replicas = 1
The Windows 7 Pro (32-bit) Results are:
DestinationAddress = 10.10.1.254
nAddress = -33486326
IcmpHandle = 2075472
Replicas = (Program hangs and never returns Replicas)
I have tried both icmp.dll and iphlpapi.dll with the same results.
I have turned off all Firewalls and disable IPv6 on the Win 7 PC.
Is there a different .dll to use on Win 7. Both dll's are in Windows 7.
Has anyone else had this problem??
Thanks,
Brad.
Using FHW+xHarbour+BCC.