• VS2010环境下Winpcap配置方法 (转)


    VS2010 配置Winpcap

    新建一个项目,GetDevs.cpp。用来测试。测试代码最后有给出。

    View->Property Manager

    Debug|Win32 -> Mircrosoft.Cpp.Win32.user(右键)->Properties

    注:此处设置为全局的!

    设置环境目录

    VC++ Directiories -> Include Directories和Library Directories中添加路径。

    假如将wpdpack放到c盘。则:

    Include Directories:c:wpdpackInclude;

    Library Directories:c:wpdpackLib;

    分号不要漏!

    设置编译条件

    C/C++下Preprocessor(预处理器)的Preprocessor Definitions(预处理定义)

    添加WPCAP;HAVE_REMOTE;

    注意分号,每个预定义符用“;”分开。


    Linker(连接器)下的Command Line(命令行)

    Additional Options (附加项)中输入:

    wpcap.lib ws2_32.lib(注:用空格分隔。)

     

    确定即可。

    Ctrl + F5运行。显示出网卡驱动信息。表明配置成功。


    代码GetDevs.cpp

    #include "pcap.h"

    void  main()

     {

       pcap_if_t *alldevs,*d;

       int i=0;

       charerrbuf[PCAP_ERRBUF_SIZE];

       

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

         {

             fprintf(stderr,"Error inpcap_findalldevs: %s ", errbuf);

            return;

         } 

        

           for(d=alldevs;d;d=d->next)

           {  printf("%d. %s", ++i,d->name);

               if(d->description)  printf(" (%s) ", d->description);

               else  printf(" (Nodescription available) ");

             }

         

              if(i==0)

             {printf(" No interfaces found! Makesure WinPcap is installed. ");

            return;

             }

     

              /*We don't need any more the device list. Free it */

           pcap_freealldevs(alldevs);

      }  

  • 相关阅读:
    day11_获取前一条用例的结果(用参数化实现)
    day11_获取前一条用例的结果
    codeforce 1433F
    codeforces 1428 D. Bouncing Boomerangs (贪心)
    codeforces 761C
    codeforces 839C
    codeforces 859C
    codeforces 858C Did you mean... (贪心)
    codeforces 855B
    st表
  • 原文地址:https://www.cnblogs.com/rainbowzc/p/4216659.html
Copyright © 2020-2023  润新知