Estoy tratando de usar esta funcion desde MINGW pero no he podido resolver las siguientes funciones:
updftp2.c:(.text+0x1ff): undefined reference to `IcmpCreateFile@0'
updftp2.c:(.text+0x270): undefined reference to `IcmpSendEcho@32'
Slds
updftp2.c:(.text+0x1ff): undefined reference to `IcmpCreateFile@0'
updftp2.c:(.text+0x270): undefined reference to `IcmpSendEcho@32'
#include "fivewin.ch"
// PRUEBA DE PING //
function main()
if WSAStartup() != 0
MsgAlert( "WSAStartup error" )
return nil
endif
if hb_Ping( GetHostByName( "www.google.com" ) ) == 0
Msginfo("Respuesta correcta del host " + AllTrim( GetHostByName( "www.google.com" ) ), "Atenci贸n" )
else
Msginfo("Host inaccesible" + AllTrim( GetHostByName( "www.google.com" ) ), "Atenci贸n" )
endif
Ping( GetHostByName( "www.google.com" ) )
WSACleanUp()
return nil
Function Ping(DestinationAddress)
Local IcmpHandle,Replicas,puerto
Local RequestData :="Probando ping",;
RequestSize :=15,;
RequestOptions:="",;
ReplyBuffer :=SPACE(278),;
ReplySize :=278,;
Timeout := 1000 && Milisegundos de espera
DEFAULT DestinationAddress := "127.0.0.1"
DestinationAddress:=LEFT(ALLTRIM(DestinationAddress)+SPACE(15),15)
MsgGet("Ping...","Ingrese una direcci贸n IP",@DestinationAddress)
IcmpHandle:=IcmpCreateFile()
Replicas :=IcmpSendEcho(IcmpHandle,;
inet_addr(DestinationAddress),;
RequestData,;
RequestSize,0,;
ReplyBuffer,;
ReplySize,;
Timeout)
IcmpCloseHandle(IcmpHandle)
IF Replicas > 0
Msginfo("Respuesta correcta del host "+ALLTRIM(DestinationAddress),"Atenci贸n")
ELSE
Msginfo("Host inaccesible"+ALLTRIM(DestinationAddress)+"Atenci贸n")
ENDIF
Return nil
//
DLL32 FUNCTION WSAGetLastError() AS _INT PASCAL FROM "WSAGetLastError" LIB "wsock32.dll"
DLL32 FUNCTION inet_addr(cIP AS STRING) AS LONG PASCAL FROM "inet_addr" LIB "wsock32.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"
#pragma BEGINDUMP
#include <hbapi.h>
#include <winsock2.h>
#include <iphlpapi.h>
#include <icmpapi.h>
int hb_Ping( const char * cp )
{
HANDLE hIcmpFile;
unsigned long ipaddr;
DWORD dwRetVal;
char SendData[32] = "Data Buffer";
LPVOID ReplyBuffer;
DWORD ReplySize;
ipaddr = inet_addr( cp );
if (ipaddr == INADDR_NONE)
return 1;
hIcmpFile = IcmpCreateFile();
if (hIcmpFile == INVALID_HANDLE_VALUE)
return 2;
ReplySize = sizeof(ICMP_ECHO_REPLY) + sizeof(SendData);
ReplyBuffer = (VOID*) malloc(ReplySize);
if (ReplyBuffer == NULL)
return 3;
dwRetVal = IcmpSendEcho(hIcmpFile, ipaddr, SendData, sizeof(SendData),
NULL, ReplyBuffer, ReplySize, 1000);
if (dwRetVal == 0)
return 4;
return 0;
}
HB_FUNC( HB_PING )
{
hb_retni( hb_Ping( hb_parc( 1 ) ) );
}
#pragma ENDDUMPSlds
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
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