HELP

解决方案 »

  1.   

    int main(int argc, char* argv[])
    {
    static char AdapterList[Max_Num_Adapter][1024];
    char szPacketBuf[600];
    char MacAddr[6]; LPADAPTER lpAdapter;
    LPPACKET lpPacket;
    WCHAR AdapterName[2048];
    WCHAR *temp,*temp1;
    ARPPACKET ARPPacket; ULONG AdapterLength = 1024;

    int AdapterNum = 0;
    int nRetCode, i; //Get The list of Adapter
    if(PacketGetAdapterNames((char*)AdapterName, &AdapterLength) == FALSE)
    {
    printf("Unable to retrieve the list of the adapters!\n");
    return 0;
    } temp = AdapterName;
    temp1=AdapterName;
    i = 0;
    while ((*temp != '\0')||(*(temp-1) != '\0'))
    {
    if (*temp == '\0') 
    {
    memcpy(AdapterList[i],temp1,(temp-temp1)*2);
    temp1=temp+1;
    i++;
    }

    temp++;
    }

    AdapterNum = i;
    for (i = 0; i < AdapterNum; i++)
    wprintf(L"\n%d- %s\n", i+1, AdapterList[i]);
    printf("\n");

    //Default open the 0
    lpAdapter = (LPADAPTER) PacketOpenAdapter((LPTSTR) AdapterList[0]);
            //取第一个网卡
            ....
    }
      

  2.   

    WinpCap自己带了例子的,因为现在没有带U盘,什么时候发给你,给个信箱吧
      

  3.   

    谢谢!我用DEBUG方式跟踪时能得到:1 - \Device\Packet_{ABC456CD-4E20-4D0F-BA5B-D2CE6C844113}
    2 - \Device\Packet_NdisWanIpPlease choose your Adapter:1
    我选1时,在打开时出错(LPADAPTER) PacketOpenAdapter(..
    GetLastError()返回2.选2时,没有这个设备。
      

  4.   

    我在用的时候一直很正常,唯一需要的修改的情况是在多网卡的情况下,需要将 WCHAR AdapterName[2048];和ULONG AdapterLength = 1024;改的更大,以免缓冲区溢出。不知道集现在调的到底是那个程序......
      

  5.   

    angusying:
    我是安装了WINCAP V2.3的,可就是不能用,能不能给我把wincap发过来?
    我的E-MAIL:[email protected]
    谢谢!
      

  6.   

    问题解决了,主要是 AdapterName[2048]; 的2048太小,我的机器有9项值,所以.....
    谢谢大家。给分了。