After Winpcap is installed, the DLL file has been installed in the c: \ windows \ system32 directory. Some header files are required to use the Winpcap library. You need to download the SDK from Winpcap.
Decompress the package to a directory. In visual studio2010, right-click the project -- properties -- VC ++ directory and add wpdpack \ include to the include directory; add wpdpack \ Lib to the library file (note that this is also the 64-bit system, rather than \ 64); in the latest Winpcap (4.1.2), if you run the following example:
#define HAVE_REMOTE#include "pcap.h"#pragma comment(lib, "Packet.lib")#pragma comment(lib, "wpcap.lib")int main(){pcap_if_t *alldevs;pcap_if_t *d;int i = 0;char errbuf[PCAP_ERRBUF_SIZE];if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1){fprintf(stderr, "Error in pcap_findalldevs_ex:%s\n", errbuf);exit(1);}for (d = alldevs; d != NULL; d = d->next){printf("%d. %s", ++i, d->name);if (d->description)printf(" (%s)\n", d->description);elseprintf(" (No description available)\n");}if (i == 0){printf("\nNo interfaces found! Make sure WinPcap is installed.\n");return 1;}pcap_freealldevs(alldevs);return 0;}
Note that the header file contains some. The test result is as follows:
Reference link: http://blog.chinaunix.net/uid-11742111-id-2833604.html