日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

VS2013 配置wincap开发环境

發布時間:2023/12/18 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 VS2013 配置wincap开发环境 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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-E594 D:\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

注意其中的LibInclude目錄的絕對路徑。
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 V9 1.\Device\NPF_{1D703AE5-7924-4C79-B98B-1E6CBB196E7A}Microsoft 2.\Device\NPF_{E3EAD4A2-27D5-47DE-8D82-372788FFBCCF}Microsoft 3.\Device\NPF_{F944E98C-E59D-4F32-BB79-84DDD9790CFC}VMware Virtual Ethernet Adapter 4.\Device\NPF_{46574547-C420-4F91-B8AE-66EA38DE3AD9}VMware Virtual Ethernet Adapter

說明 配置成功!

注意:
1.需要在依賴庫添加wpcap.lib;Packet.lib;ws2_32.lib ,這三個庫

2.需要配置正確的Include 目錄和Lib目錄

總結

以上是生活随笔為你收集整理的VS2013 配置wincap开发环境的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。