有一个应用程序A,里头调用了pcap_findalldevs函数
通过远程桌面连接到一台机器上,并以管理员Administrator登陆,运行A,pcap_findalldevs得到的却是空列表。请问这可能是什么原因呢?谢谢。

解决方案 »

  1.   

    你用的pacp包的函数,远程机器有安装winpacp么
      

  2.   

    运行编译好的程序也需要安装winpacp?
      

  3.   


    刚才检查了下,远程机器有安装winpacp
      

  4.   

    需要。winpcap不是被你编译到程序里的,winpcap的最终安装其实是给系统添加了一层协议驱动
      

  5.   

    你需要带上winpcap的相关dll,以及安装它的sys等驱动文件到远程机器
      

  6.   


    安装winpcap包的过程就已经有那些 sys了,无需拷贝。我在使用中也没这样做过拷贝操作。
      

  7.   

    刚才做了个小试验,在机器aa(XP)编译下面代码得到PcapTest.exe,运行有结果;拷贝PcapTest.exe到机器bb(XP),在bb运行(非远程桌面连接)有结果;拷贝PcapTest.exe到机器cc(server 2003),远程桌面连接,以管理员身份登录cc,运行PcapTest.exe,报错The system cannot execute the specified program.aa, bb, cc这三台机器都装了winpcap 4.0.2#include "pcap.h"
    #include <stdio.h>int main()
    {
    pcap_if_t *alldevs;
    pcap_if_t *d;
    int i=0;
    char errbuf[PCAP_ERRBUF_SIZE]; /* Retrieve the device list */
    if (pcap_findalldevs(&alldevs, errbuf) == -1)
    {
    fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf);
    exit(1);
    } /* Print the list */
    for(d=alldevs;d;d=d->next)
    {
    printf("%d. %s", ++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 -1;
    } /* We don't need any more the device list. Free it */
    pcap_freealldevs(alldevs); return(0);
    }
      

  8.   

    补充一下,从bb远程桌面登录到aa,运行PcapTest.exe,有结果;
    从aa远程桌面登录到bb,运行PcapTest.exe,有结果;
      

  9.   

    不是系统的问题吧?如果是的话,为啥那么简单的几行代码编译出来的东西就不能在server 2003运行捏?
      

  10.   

    VS2003以上编译的程序,需要framework支持,缺乏一些动态库你把编译选项里的代码生成改下:我的是2005,我说下路径:项目-->XXX(工程名)属性-->配置属性-->c/c++--->代码生成然后在右边把  运行时库  选为Mtddebug和release都要设置
      

  11.   

    刚才做了个小试验,在机器aa(XP)编译下面代码得到PcapTest.exe,运行有结果;拷贝PcapTest.exe到机器bb(XP),在bb运行(非远程桌面连接)有结果;拷贝PcapTest.exe到机器cc(server 2003),远程桌面连接,以管理员身份登录cc,运行PcapTest.exe,报错The system cannot execute the specified program. aa, bb, cc这三台机器都装了winpcap 4.0.2 C/C++ code
    #include "pcap.h"
    #include <stdio.h>int main()
    {
        pcap_if_t *alldevs;
        pcap_if_t *d;
        int i=0;
        char errbuf[PCAP_ERRBUF_SIZE];    /* Retrieve the device list */
        if (pcap_findalldevs(&alldevs, errbuf) == -1)
        {
            fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf);
            exit(1);
        }    /* Print the list */
        for(d=alldevs;d;d=d->next)
        {
            printf("%d. %s", ++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 -1;
        }    /* We don't need any more the device list. Free it */
        pcap_freealldevs(alldevs);    return(0);
    }