1,316
社区成员
发帖
与我相关
我的任务
分享
// Declare and initialize variables
char[] SendData = "Data Buffer";
LPVOID ReplyBuffer;
ReplyBuffer = (VOID*) malloc(sizeof(ICMP_ECHO_REPLY) + sizeof(SendData));
if ((dwRetVal = IcmpSendEcho(hIcmpFile,
inet_addr("123.456.789.0"),
SendData, sizeof(SendData) + sizeof(ICMP_ECHO_REPLY),
NULL, ReplyBuffer,
sizeof(SendData),
1000)) != 0) {
PICMP_ECHO_REPLY pEchoReply = (PICMP_ECHO_REPLY)ReplyBuffer;
printf("\tReceived %ld messages.\n", dwRetVal);
printf("\tMessage: %s\n", pEchoReply->Data);
}
else {
printf("\tCall to IcmpSendEcho() failed.\n");
printf("\tError: %ld\n", GetLastError());
}