void CWinreplayDlg::OnButtonStartcapture() //一个按钮“开始捕获”的消息响应函数
{
pcap_if_t *alldevs;
pcap_if_t *d;
int inum;
int i=0;
pcap_t *adhandle;
char errbuf[PCAP_ERRBUF_SIZE];
pcap_dumper_t *dumpfile;
CString tempbuff;////////////////////////////////其他代码/////////////////////////////////* 打开适配器*/
if ( (adhandle = pcap_open_live(d->name, // name of the device
65536, // portion of the packet to capture.
// 65536 grants that the whole packet will be captured on all the MACs.
1, // promiscuous mode
1000, // read timeout
errbuf // error buffer
) ) == NULL)
{
................ /* 释放设备列表 */
pcap_freealldevs(alldevs);
return ;
} /* 打开嗅探文件 */
dumpfile = pcap_dump_open(adhandle, "c:\\capture.txt");
......................................其他代码
/* 开始捕获 */
pcap_loop(adhandle, 0, packet_handler, (unsigned char *)dumpfile);//winpcap库中的函数,包含死循环,当点击“开始捕获”按钮后,其他的按钮都无法点击,程序就象死掉一样。 return ;
}要求:使用_beginthreadex( )开启一个线程,使得用户可以点击对话框中的“停止捕获”按钮,当点击停止捕获按钮后,捕获结束,但是对话框不消失。请高手给我写一下具体的代码!!!!拜托了
{
pcap_if_t *alldevs;
pcap_if_t *d;
int inum;
int i=0;
pcap_t *adhandle;
char errbuf[PCAP_ERRBUF_SIZE];
pcap_dumper_t *dumpfile;
CString tempbuff;////////////////////////////////其他代码/////////////////////////////////* 打开适配器*/
if ( (adhandle = pcap_open_live(d->name, // name of the device
65536, // portion of the packet to capture.
// 65536 grants that the whole packet will be captured on all the MACs.
1, // promiscuous mode
1000, // read timeout
errbuf // error buffer
) ) == NULL)
{
................ /* 释放设备列表 */
pcap_freealldevs(alldevs);
return ;
} /* 打开嗅探文件 */
dumpfile = pcap_dump_open(adhandle, "c:\\capture.txt");
......................................其他代码
/* 开始捕获 */
pcap_loop(adhandle, 0, packet_handler, (unsigned char *)dumpfile);//winpcap库中的函数,包含死循环,当点击“开始捕获”按钮后,其他的按钮都无法点击,程序就象死掉一样。 return ;
}要求:使用_beginthreadex( )开启一个线程,使得用户可以点击对话框中的“停止捕获”按钮,当点击停止捕获按钮后,捕获结束,但是对话框不消失。请高手给我写一下具体的代码!!!!拜托了
解决方案 »
- vc++如何调用TOP api?
- 求源码: 现求VC的进销存源码, 或者数据库表也行, 越简单越好
- 用户不能添加到总是失败,怎么用?
- 初始化时报错,谢谢我是初学者不知道怎么搞
- 我要如何编程才能从摄像头取到图像??
- 谁能告诉我实现能在网页上运行的Activex控件的代码吗??
- 如何自动关闭一个对话框?
- 我决定转行,学习无线电了,,,,,
- 又是字符串转换,UniCode CString 转成 MBCS 的CString
- 请问如何在DLL中存放全局变量??详情请进--》
- 请各位大侠帮帮忙!!散分的!!!
- socket--send问题:非阻塞发送时,返回值表示发送至缓冲区的字节数,我怎么才能知道数据何时真的发送出去?
for(int i=0;I<threadNum;i++)
{
HANDLE hThread;
DWORD dwthreadId;
hThread = _beginthreadex(NULL,ServerWorkThrea, (LPVOID)hCompletePort,0,&dwthreadId);
CloseHandle(hThread);
}
CloseHandle(hThread)在程序代码中的作用是在工作线程在结束后,能够自动销毁对象作用。