INFO: Implementing Internet Pings Using Icmp.dll


Summary


Icmp.dll provides functionality that allows developers to write Internet ping applications on Windows systems without Winsock 2 support. The .h and .lib files needed in order to use Icmp.dll were provided with previous versions of Win 32 SDK in the MSTOOLS\ICMP directory. The current Platform SDK release includes only the icmp.lib file. A Readme.txt (copied below) and the .h files from previous versions of the Win 32 SDK were, and still are, the only documentation available. In the current version of the Platform SDK, these files are located in the Platform SDK Root\Misc\Icmp directory.


If you are writing new code intended for platforms that support Winsock 2.0 or better, you should use the Winsock 2 raw sockets support demonstrated in the Platform SDK sample titled "Ping: SOCK_RAW in Winsock 2.0" available in MSSDK\samples\win32\winsock2\ping. As noted in the Readme.txt, Icmp.dll may be removed from future versions of Windows. Please note, however, that for Windows NT and Windows 2000 implementations, Raw Sockets are subject to security checks and are accessible only to members of the administrator's group. For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

195445 PRB: Raw Socket Access Denied to Non-Admin Windows NT 4.0 and Windows 2000 Users

Support of Icmp.dll is limited to providing the information in this article and the .h files that accompany Icmp.dll.


Note that the Winsock 1.1 WSAStartup function must be called prior to using the functions exposed by ICMP.DLL. If you do not do this, the first call to IcmpSendEcho will fail with error 10091 (WSASYSNOTREADY).



------------ ICMP README.TXT ---------------

[DISCLAIMER]


We have had requests in the past to expose the functions exported from icmp.dll. The files in this directory are provided for your convenience in building applications which make use of ICMPSendEcho().


Notice that the functions in icmp.dll are not considered part of the Win32 API and will not be supported in future releases. Once we have a more complete solution in the operating system, this DLL, and the functions it exports, will be dropped.



[DOCUMENTATION]


The ICMPSendEcho() function sends an ICMP echo request to the specified destination IP address and returns any replies received within the timeout specified. The API is synchronous, requiring the process to spawn a thread before calling the API to avoid blocking. An open IcmpHandle is required for the request to complete. IcmpCreateFile() and IcmpCloseHandle() functions are used to create and destroy the context handle.


See also icmpapi.h.