FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Pinging from Windows 7 (32-bit)??
Posts: 27
Joined: Fri Jan 11, 2008 09:58 PM
Pinging from Windows 7 (32-bit)??
Posted: Wed Oct 19, 2011 02:52 PM
I am using a Ping(DestinationAddress) Function I found on this forum. It works great in XP, but hangs the program in Windows 7 32-bit. Here is the function and the results that are displayed.

Code (fw): Select all Collapse
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.
Posts: 302
Joined: Fri Apr 23, 2010 04:30 AM
Re: Pinging from Windows 7 (32-bit)??
Posted: Wed Oct 19, 2011 09:06 PM
Hello,

This function crash in windows 7 and Windows 8 use solution by Daniel Garcia In this link.

http://forums.fivetechsupport.com/viewtopic.php?f=6&t=20679&hilit=ping

I tested both and works fine in Windows 8 too.

Regards,

Nicanor
Nicanor Martinez M.
Auditoria y Sistemas Ltda.
MicroExpress Ltda.
FW + FWH + XHARBOUR + HARBOUR + PELLES C + XDEVSTUDIO + XEDIT + BCC + VC_X86 + VCC_X64 + MINGW + R&R Reports + FastReport + Tdolphin + ADO + MYSQL + MARIADB + ORACLE
nnicanor@yahoo.com
Posts: 27
Joined: Fri Jan 11, 2008 09:58 PM
Re: Pinging from Windows 7 (32-bit)??
Posted: Thu Oct 20, 2011 07:10 PM

Finally fixed and working in Winows 7.
Thanks for the code samples, they were great.
I had to do a LoadLib32("iphlpapi.dll") to get it to work in Windows 7 and it worked in XP without it. ??????

Thanks,

Brad.

Continue the discussion