专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > VC

请问一个用WinPcap编写的例子

发布时间:2011-06-23 14:13:00 文章来源:www.iduyao.cn 采编人员:星星草
请教一个用WinPcap编写的例子
在网上找了一个调用WinPcap的例子,但是用VS2005编译得到下面的错误
1> netflow.cpp
1> c:\try\netflow\netflow\netflow.cpp(210)   :   error   C2664:   'localtime '   :   cannot   convert   parameter   1   from   'const   long   *__w64   '   to   'const   time_t   * '
1>                 Types   pointed   to   are   unrelated;   conversion   requires   reinterpret_cast,   C-style   cast   or   function-style   cast
1> ws2_32.lib
1> c1xx   :   fatal   error   C1083:   Cannot   open   source   file:   'ws2_32.lib ':   No   such   file   or   directory
1> wpcap.lib
1> c1xx   :   fatal   error   C1083:   Cannot   open   source   file:   'wpcap.lib ':   No   such   file   or   directory
1> Generating   Code...
1> Build   log   was   saved   at   "file://c:\try\netflow\netflow\Debug\BuildLog.htm "
1> netflow   -   3   error(s),   0   warning(s)
==========   Build:   0   succeeded,   1   failed,   0   up-to-date,   0   skipped   ==========

2005用的不熟,好像是语法不支持VC6.0的,请问该怎么该啊?
还有,就是这个程序用VC6.0编译成功后,在VC6.0的那台电脑(XP   HOME)上只能显示猫的网络适配器,100M和无线网卡都不显示。但是在另外一台电脑上(XP   PRO+2005NET)却能显示所有网络适配器。请问这是为什么啊?

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//下面是一个应用winpcap写的一个网络流量统计的例子,

//   nettraffic.cpp   :   Defines   the   entry   point   for   the   console   application.

//

#include   <pcap.h>

#include   <remote-ext.h>

#include   <iostream>

#include   <winsock2.h>


using   namespace   std;

//------------------------------------


//------------------------------------

void   dispatcher_handler(u_char*   user_data,   const   struct   pcap_pkthdr   *   pkthdr,   const   u_char   *pktdata);


//------------------------------------

int   main(int   argc,   char*   argv[])

{

                int                                                                                 i;

                pcap_if_t*                                                       alldevs;

                pcap_if_t*                                                       dev;

                char                                                             errorbuf[PCAP_ERRBUF_SIZE];
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: