Click to Rate and Give Feedback
MSDN
MSDN Library
Networking
Network Protocols
IP Helper
IP Helper Reference
IP Helper Functions
 IcmpCreateFile Function
IcmpCreateFile Function

The IcmpCreateFile function opens a handle on which IPv4 ICMP echo requests can be issued.

Syntax

HANDLE IcmpCreateFile(void);

Parameters

This function has no parameters.

Return Value

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.

Remarks

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. OS 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.

Examples

The following example opens a handle on which ICMP echo requests can be issued.

 #include <iphlpapi.h>
#include <icmpapi.h>

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");

Requirements

Client Requires Windows Vista, Windows XP, or Windows 2000 Professional.
Server Requires Windows Server 2008, Windows Server 2003, or Windows 2000 Server.
Header

Declared in Icmpapi.h.

Library

Use Iphlpapi.lib.

DLL

Requires Iphlpapi.dll on Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP.

Requires Icmp.dll on Windows 2000 Server and Windows 2000 Professional.

See Also

GetLastError
Icmp6CreateFile
Icmp6ParseReplies
Icmp6SendEcho2
IcmpCloseHandle
IcmpParseReplies
IcmpSendEcho
IcmpSendEcho2
IcmpSendEcho2Ex


Send comments about this topic to Microsoft

Build date: 7/31/2008

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker