C++Builder 程序员博客
2 Sep
BCB如何调用WINPCAP?
我们老师要我用BCB写一个抓包的程序,要用到winpcap.请问BCB是怎么调用winpcap的啊!或许我的提问方式不恰当。总之,BCB怎么和winpcap发生关系的啊?我们老师给我了一个用VC写的抓包程序的源代码,请问对我们有多大的参考价值啊?谢谢!
下面是我在百度上面提问时他们给我的答案,可我就是看不懂
“VC中写的代码不需要大的修改就可以在BCB中运行, 但是由于原有的lib是为VC++写的,所以建议用BCB的implib工具重新生成BCB可用的LIB文件,并将其导入你的BCB工程中并将需要的DLL文件复制到工程的DEBUG目录或者RELEASE目录中,包含头文件,然后可以调用WINPCAP API写程序。 当然,前提是已经安装了WINPCAP”
谢谢!!!
还有,我直接把下面的程序放在BCB控制台上调试,怎么编译时说找不到 <pcap.h>
#include <pcap.h>
#include <stdlib.h>
#include <stdio.h>
#pragma comment(lib,"wpcap.lib")
int main(int argc, int argv[])
{
pcap_if_t *alldevs;
pcap_if_t *d;
int i=0;
char errbuf[PCAP_ERRBUF_SIZE];
/* Retrieve the device list from the local machine */
if (pcap_findalldevs(&alldevs, errbuf) == -1)
{
fprintf(stderr,"Error in pcap_findalldevs_ex: %s\n", errbuf);
exit(1);
}
/* Print the list */
for(d= alldevs; d != NULL; d= d->next)
{
printf("%d. %s\n", ++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 0;
}
return -1;
}
/* We don't need any more the device list. Free it */
pcap_freealldevs(alldevs);
我到底怎么做才能调用WINPCAP啊?谢谢!!!
这种标准的C程序在CB和VC里都是一样的
Winpcap使用C写的,VC和BCB的使用方法一样。
能不能讲的再详细一点啊?我没有学过VC,BCB也只是学了一学期钱能的书,知识太有限了,让大家见笑了。
你google肯定能找到一大片代码的,照着用就是了