Declare Function IcmpSendEcho Lib "icmp.dll" (icmpHandle as IntPtr, destinationAddress as Int32, requestData as IntPtr, requestSize as Int16, requestOptions as IntPtr, replyBuffer as IntPtr, replySize as Int32, timeout as Int32) As Int32
replyBuffer receives an ICMP_ECHO_REPLY followed by zero or more bytes of reply data for each reply received.
Tips & Tricks:
Please add some!
Complete "simple sample" coded by Aprelov Sergey:
public class IcmpPing
private struct ICMP_OPTIONS
public byte Ttl;
public byte Tos;
public byte Flags;
public byte OptionsSize;
public IntPtr OptionsData;
private struct ICMP_ECHO_REPLY
public int Address;
public int Status;
public int RoundTripTime;
public short DataSize;
public short Reserved;
public IntPtr DataPtr;
public ICMP_OPTIONS Options;
public string Data;
private static extern IntPtr IcmpCreateFile();
private static extern bool IcmpCloseHandle(IntPtr handle);
private static extern int IcmpSendEcho(IntPtr icmpHandle, int destinationAddress, string requestData, short requestSize, ref ICMP_OPTIONS requestOptions, ref ICMP_ECHO_REPLY replyBuffer, int replySize, int timeout);
public bool Ping(IPAddress ip)
IntPtr icmpHandle = IcmpCreateFile();
ICMP_OPTIONS icmpOptions = new ICMP_OPTIONS();
icmpOptions.Ttl = 255;
ICMP_ECHO_REPLY icmpReply = new ICMP_ECHO_REPLY();
string sData = "x";
Describes the options to be included in the header of an IP packet.
3/16/2007 2:17:22 PM - -184.108.40.206
An IntPtr is a pointer to a memory location (unmanaged) that adapts to the platform it is running on (64-bit, etc.) UNLIKE a standard int/Integer. You should always use this type for unmanaged calls that require it, even though an int will appear to work on your development machine.
1/13/2008 11:00:13 AM - tsahi-220.127.116.11
Describes the data returned in response to an echo request.