VS2013 配置wincap开发环境
来源:互联网 发布:淘宝注册帐号 编辑:程序博客网 时间:2024/06/11 09:13
1.下载wincap安装包
下载驱动包:
https://www.winpcap.org/install/bin/WinPcap_4_1_3.exe
安装驱动。
下载开发包:
https://www.winpcap.org/install/bin/WpdPack_4_1_2.zip
将开发包解压至某ansic目录,例如:U:\libs目录下
目录结构如下:
D:\>tree libs文件夹 PATH 列表卷序列号为 B268-E594D:\LIBS└─WpdPack_4_1_2 └─WpdPack ├─docs │ └─html ├─Examples-pcap │ ├─basic_dump │ ├─basic_dump_ex │ ├─iflist │ ├─pcap_filter │ ├─pktdump_ex │ ├─readfile │ ├─readfile_ex │ ├─savedump │ ├─sendpack │ └─UDPdump ├─Examples-remote │ ├─iflist │ ├─misc │ ├─PacketDriver │ │ ├─GetMacAddress │ │ ├─TestPacketCapture │ │ └─TestPacketSend │ ├─pcap_filter │ ├─pcap_fopen │ ├─pktdump_ex │ ├─sendcap │ ├─smp_1 │ ├─tcptop │ ├─UDPdump │ └─UserLevelBridge ├─Include │ └─pcap └─Lib └─x64
注意其中的Lib和Include目录的绝对路径。
2.打开vs,新建C++空白项目
3.在新的项目里面,
打开项目属性,。
设置项目属性
3.1设置include 目录,将开发包里面的Include目录包含进行。
3.2设置lib目录,将开发包里面的Lib目录包含进入(如果目标是64位的程序,将需要Lib\X64目录。
3.3 设置链接库:
在 配置->链接器->输入 的Addtional Dependencies 栏里面添加:wpcap.lib;Packet.lib;ws2_32.lib 这三个链接库。
链接ws2_32.lib的原因是:
Set the options of the linker to include the winsock library file
ws2_32.lib. This file is distributed with the C compiler and contains
the socket functions for Windows. It is needed by some functions used
by the samples in the tutorial.
3.4 设置权限
在在 配置->链接器->配置(Manifest File) 的UAC Execution level 栏里面设置 requireAdministrator (/level=’requireAdministrator’)
3.5 关闭vs的乱七八糟的警报
在C/C++ ->通用 中设置 Waring Level的值为“Turn off All Warning” 表示关闭所有警告,设置SDL checks为“No”
4.测试
测试代码:
#include <stdio.h>#include <stdlib.h>#include <pcap-stdinc.h> //这一句在有些Win系统不能少!#include <pcap.h>int main(){ pcap_if_t * alldevs; pcap_if_t * d; char errBuf[PCAP_ERRBUF_SIZE]; if (pcap_findalldevs(&alldevs, errBuf)) //获取所有设备 { printf("Error in pcap_findalldev\n"); exit(-1); } int i = 0; for (auto each = alldevs; each != NULL; each = each->next) { printf("%d.%s", i++, each->name); if (each->description) { printf("%s\n", each->description); } else { printf("No description.\n"); } } if (i == 0) { printf("\n No interfaces found.\n"); } pcap_freealldevs(alldevs); system("pause"); return 0;}
结果:
0.\Device\NPF_{1D8AD263-6CDA-4C2C-A6C2-0F6F8853EECD}TAP-Windows Adapter V91.\Device\NPF_{1D703AE5-7924-4C79-B98B-1E6CBB196E7A}Microsoft2.\Device\NPF_{E3EAD4A2-27D5-47DE-8D82-372788FFBCCF}Microsoft3.\Device\NPF_{F944E98C-E59D-4F32-BB79-84DDD9790CFC}VMware Virtual Ethernet Adapter4.\Device\NPF_{46574547-C420-4F91-B8AE-66EA38DE3AD9}VMware Virtual Ethernet Adapter
说明 配置成功!
注意:
1.需要在依赖库添加wpcap.lib;Packet.lib;ws2_32.lib ,这三个库
2.需要配置正确的Include 目录和Lib目录
- VS2013 配置wincap开发环境
- Wincap开发环境搭建
- VS2013+FFMPEG开发环境配置
- vs2013开发php环境配置
- FFmpeg+VS2013开发环境配置
- vs2013配置OpenGL开发环境
- VS2013/VS20DirectShow开发环境配置
- VS2013配置Winpcap开发环境
- 配置OpenCV+VS2013开发环境
- VS2013配置proCC++开发环境
- VS2013配置Caffe开发环境
- vs2010环境下wincap的配置
- 关于vs2013配置Opencv开发环境
- OpenCV 2.4.9 +VS2013 开发环境配置
- QT5+VS2013软件开发环境配置
- Cordova 10 VS2013配置cordova开发环境
- OpenCV3.1.0+VS2013开发环境配置
- VS2013的OSG开发环境配置
- MySQL——插入、更新、删除数据
- mysql踩坑实战
- python判断字符串
- 用TensorFlow 进行Logistic回归
- DNS基本概念&报文格式
- VS2013 配置wincap开发环境
- 文件和目录权限chmod 、更改所有者和所属组chown 、 umask、 隐藏权限lsattr/chattr
- Elasticsearch 5.x Head插件部署指南
- DNS协议详解
- centos nginx django+virtualenv部署
- idea Could not determine the class-path for interface org.jetbrains.kotlin.gradle.KotlinGradleModel.
- 8. chmod chown umask lsattr chattr
- 深入理解DNS报文格式
- 域名跳转