Events
Apr 8, 3 PM - May 28, 7 AM
Sharpen your AI skills and enter the sweepstakes to win a free Certification exam
Register now!This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The IcmpCreateFile function opens a handle on which IPv4 ICMP echo requests can be issued.
IPHLPAPI_DLL_LINKAGE HANDLE IcmpCreateFile();
The IcmpCreateFile function returns an open handle on success. On failure, the function returns INVALID_HANDLE_VALUE. Call the GetLastError function for extended error information.
The IcmpCreateFile function is exported from the Icmp.dll on Windows 2000. The IcmpCreateFile function is exported from the Iphlpapi.dll on Windows XP and later. Windows version checking is not recommended to use this function. Applications requiring portability with this function across Windows 2000, Windows XP, Windows Server 2003 and later Windows versions should not statically link to either the Icmp.lib or the Iphlpapi.lib file. Instead, the application should check for the presence of IcmpCreateFile in the Iphlpapi.dll with calls to LoadLibrary and GetProcAddress. Failing that, the application should check for the presence of IcmpCreateFile in the Icmp.dll with calls to LoadLibrary and GetProcAddress.
For IPv6, use the Icmp6CreateFile, Icmp6SendEcho2, and Icmp6ParseReplies functions.
Note that the include directive for Iphlpapi.h header file must be placed before the Icmpapi.h header file.
The following example opens a handle on which ICMP echo requests can be issued.
#include <windows.h>
#include <stdio.h>
#include <iphlpapi.h>
#include <icmpapi.h>
// Need to link with Iplhlapi.lib
#pragma comment(lib, "IPHLPAPI.lib")
void main()
{
HANDLE hIcmpFile;
hIcmpFile = IcmpCreateFile();
if (hIcmpFile == INVALID_HANDLE_VALUE) {
printf("\tUnable to open handle.\n");
printf("IcmpCreatefile returned error: %ld\n", GetLastError() );
}
else {
printf("\tHandle created.\n");
// Need to close the handle when done using it
IcmpCloseHandle(hIcmpFile);
}
}
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps | UWP apps] |
Minimum supported server | Windows 2000 Server [desktop apps | UWP apps] |
Target Platform | Windows |
Header | icmpapi.h |
Library | Iphlpapi.lib |
DLL | Iphlpapi.dll on Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP; Icmp.dll on Windows 2000 Server and Windows 2000 Professional |
IcmpSendEcho
Events
Apr 8, 3 PM - May 28, 7 AM
Sharpen your AI skills and enter the sweepstakes to win a free Certification exam
Register now!