您的位置:首页 > 其它

wincap HelloWorld

2016-10-10 14:23 274 查看
#define WIN32
#define HAVE_REMOTE
#include <stdlib.h>
#include "pcap.h"
#include "remote-ext.h"
#pragma comment(lib,"wpcap.lib")
#pragma comment(lib,"ws2_32.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 /* auth is not needed */, &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);
else
printf(" (No description available)\n");
}

if (i == 0)
{
printf("\nNo interfaces found! Make sure WinPcap is installed.\n");
return 0;
}
system("pause");
/* 不再需要设备列表了,释放它 */
pcap_freealldevs(alldevs);
}


代码是官网文档中拿来的

官网的代码有很多问题,自己改了下,可以运行vs2013

静态库和头文件路径需要自己配置

http://www.ferrisxu.com/WinPcap/html/index.html

http://www.winpcap.org/devel.htm

http://www.winpcap.org/

我下的是4.13的exe,4.12的sdk

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  wincap