winpcap4.0下载(win10安装winpcap)

更新时间:2025-06-24  版本:v0624

大家好,今天给各位分享winpcap4.0下载的一些知识,其中也会对win10安装winpcap进行解释,文章篇幅可能偏长,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在就马上开始吧!

如何在VC中配置winPcap开发环境

VC6.0中使用winpcap

winpcap4.0下载(win10安装winpcap)

1.下载winpcap的安装包,程序员开发包。(两个包)

2.执行安装包,这样你的机子就能运行winpcap程序了

3.解压开发包,在VC的option的include和lib中加入winpcap的include和lib

4.在工程的setting中导入wpcap.lib和Packet.lib库

VC.net中使用winpcap

winpcap4.0下载(win10安装winpcap)

1、在项目-〉属性-〉C++-〉常规标签的附加包含目录中包含WinPcap的Include目录

2、在项目-〉属性-〉链接器-〉输入标签的附加依赖项中添加lib库文件

在Microsoft的VC++中使用wpcap.dll创建应用的步骤如下:

在需要调用wpcap.dll动态连接库的功能和函数的所有源代码文件的开头引用头文件pcap.h;

如果应用程序使用了Winpcap的Win32相关函数,记住在预处理定义中需要引用WPCAP;

在编译连接选项Link中设置包括wpcap.lib库文件,wpcap.lib在Winpcap开发补丁中找到;

在编译连接选项中设置包含winsock库函数(比如wsock32.lib)。这个文件由C编译器提供,包含了Windows环境下的socket函数,有些libpcap函数也需要调用它。

还要记住:

为了增加预处理定义,必须在Project菜单中选择Settings,在tab控件中选择C/C++页面,在Category下拉框中选择General,在Preprocessor Definitions文本框中加入预定义。

为了在Microsoft VC++项目中增加一个新库连接,需要从菜单Project中选择Settings,再在tab控件中选择Link,然后在Objcet/library modules编辑框中加入要加入的新连接库名字。

为了在Microsoft VC++项目中加入一个新的库文件搜索路径,必须从Tools菜单中选择Options,然后在tab控件中选择Directories页面,在Show Directories for下拉框中选择Library files,在Directories列表框中加入到要加入的库文件路径。

为了在Microsoft VC++中加入一条路径以便编译器能够找到包含文件,需要从Tools菜单中选择Options,在tab控件中选择Directories页面,从Show Directories for下拉框中选择Include files,在Directories列表框中加入到要加入的包含头文件路径。

一)首先安装winpcap驱动,可以到winpcap官方网站上下载:

安装winpcap驱动后:

1. C:\WINDOWS\system32目录下自动生成: wpcap.dll,packet.dll

2. C:\WINDOWS\system32\drivers下自动生成:npf.sys

(二)winpcap-4.0.3配置环境:

在项目->XX属性,选择配置属性:

1. c/c++->常规\附加包含目录:D:\WpdPack-4.0.3\Include

->预处理器\预处理器定义:WPCAP

2.链接器->常规\附加库目录:D:\WpdPack-4.0.3\Lib

->输入\附加依赖项: Packet.lib wpcap.lib ws2_32.lib

(三)新建一个空WIN32控制台项目,添加。C文件:

#include"pcap.h"

int main()

{

pcap_if_t*alldevs;

pcap_if_t*d;

int inum;

int i=0;

pcap_t*adhandle;

int res;

char errbuf[PCAP_ERRBUF_SIZE];

struct tm*ltime;

char timestr[16];

struct pcap_pkthdr*header;

const u_char*pkt_data;

time_t local_tv_sec;

/* Retrieve the device list*/

if(pcap_findalldevs(&alldevs, errbuf)==-1)

{

fprintf(stderr,"Error in pcap_findalldevs:%s\n", errbuf);

return-1;

}

/* Print the list*/

for(d=alldevs; d; 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-1;

}

printf("Enter the interface number(1-%d):",i);

scanf("%d",&inum);

if(inum< 1|| inum> i)

{

printf("\nInterface number out of range.\n");

/* Free the device list*/

pcap_freealldevs(alldevs);

return-1;

}

/* Jump to the selected adapter*/

for(d=alldevs, i=0; i< inum-1;d=d->next, i++);

/* Open the adapter*/

if((adhandle= pcap_open_live(d->name,// name of the device

65536,// portion of the packet to capture.

// 65536 grants that the whole packet will be captured on all the MACs.

1,// promiscuous mode(nonzero means promiscuous)

1000,// read timeout

errbuf// error buffer

))== NULL)

{

fprintf(stderr,"\nUnable to open the adapter.%s is not supported by WinPcap\n", d->name);

/* Free the device list*/

pcap_freealldevs(alldevs);

return-1;

}

printf("\nlistening on%s...\n", d->description);

/* At this point, we don't need any more the device list. Free it*/

pcap_freealldevs(alldevs);

/* Retrieve the packets*/

while((res= pcap_next_ex( adhandle,&header,&pkt_data))>= 0){

if(res== 0)

/* Timeout elapsed*/

continue;

/* convert the timestamp to readable format*/

local_tv_sec= header->ts.tv_sec;

ltime=localtime(&local_tv_sec);

strftime( timestr, sizeof timestr,"%H:%M:%S", ltime);

printf("%s,%.6d len:%d\n", timestr, header->ts.tv_usec, header->len);

}

if(res==-1){

printf("Error reading the packets:%s\n", pcap_geterr(adhandle));

return-1;

}

pcap_close(adhandle);

return 0;

}

编译,运行!

(三)在工具\选项\项目\VC++项目\可执行文件添加: D:\WpdPack-4.0.3\Include D:\WpdPack-4.0.3\Lib

D:\WpdPack-4.0.3\Include(包含文件)和D:\WpdPack-4.0.3\Lib(库文件)

c语言如何配置pcap.h

首先要下载一个WinPcap4.0.1,将其安装至电脑。

Microsoft Visual C++创建一个使用 wpcap.dll的应用程序,需要按一下步骤:

在每一个使用了库的源程序中,将 pcap.h头文件包含(include)进来。

如果你在程序中使用了WinPcap中提供给Win32平台的特有的函数,记得在预处理中加入WPCAP的定义。

如果你的程序使用了WinPcap的远程捕获功能,那么在预处理定义中加入HAVE_REMOTE。不要直接把remote-ext.h直接加入到你的源文件中去。

设置VC++的链接器(Linker),把wpcap.lib库文件包含进来。wpcap.lib可以在WinPcap中找到。

设置VC++的链接器(Linker),把ws2_32.lib库文件包含进来。这个文件分布于C的编译器,并且包含了Windows的一些socket函数。本教程中的一些范例程序,会需要它。

记住以下几点:

要添加一个预处理定义,你需要打开Project菜单,选择Settings,然后选择C/C++选项卡,在General类下,你必须在Preprocessor Definitions下的文本框中添加定义。

要在一个VC++6.0工程中,添加一,个新的库,你必须打开Project菜单,选择Settings,然后选择Link选项卡,然后把新库的名字添加到Object/Library modules下的文本框中

要向VC++6.0中添加一个新的库所在的路径,你必须打开Tool菜单,选择Options,然后选择Directories选项卡,在Show directories下拉框中选择Library files,并且将新的路径添加到Directories中去

要向VC++6.0中添加一个新的包含文件所在的路径,你必须打开Tool菜单,选择Options,然后选择Directories选项卡,在Show directories下拉框中选择Include files,并且将新的路径添加到Directories中去。

问题回答完毕。

如果你想使用WINPCAP编辑一个进行抓包,分析,发送数据包等功能的程序,请参考我的空间: