本帖最后由 VisualEleven 于 2010-10-29 15:55:19 编辑

解决方案 »

  1.   


    a=inet_addr((const char*)strIP.GetBuffer());
    a = htonl(a);//to network order
    struct hostent* host=gethostbyaddr((char*)&a,4,AF_INET);struct hostent* FAR gethostbyaddr(
      __in  const char *addr,
      __in  int len,
      __in  int type
    );
    Parameters
    addr [in]
    A pointer to an address in network byte order.

    len [in]
    The length, in bytes, of the address.type [in]
    The type of the address, such as the AF_INET address family type (used with TCP, UDP, and other associated Internet protocols). Possible values for the address family are defined in the Winsock2.h header file. On the Windows SDK released for Windows Vista and later,, the organization of header files has changed and the possible values for the address family are defined in the Ws2def.h header file. Note that the Ws2def.h header file is automatically included in Winsock2.h, and should never be used directly.
      

  2.   

    此外看看你的工程属性是不是一致.VS2005没用过,不知道是不是默认Unicode字符集。
      

  3.   

    VS2005工程默认都是Unicode工程。
    GetDlgItemText(IDC_IP,strIP);取得的字符串是Unicode字符串。需要转换成为多字节字符串。
    使用这个函数WideCharToMultiByte进行转换即可。
    具体参数用法请查阅MSDN。
      

  4.   

    1>mt.exe : general error c101008a: Failed to save the updated manifest to the file ".\Debug\Neighbor.exe.embed.manifest". Bpcn上述错误是改变字符集(改变成多字节字符集)之后生成的(我用的是vs2005),直接运行没有问题,可是总是有这个错误产生,很不爽,求解
      

  5.   

    查看一下WSAGetLastError()函数的返回值是什么?
      

  6.   

    gethostbyaddr 好像只有 ANSI 。
    6楼多半说的对!
      

  7.   

    难道是我说的不够明白?将工程设置为多字节之后直接运行是可以的,但是编译的时候会出现
    1>mt.exe : general error c101008a: Failed to save the updated manifest to the file ".\Debug\Neighbor.exe.embed.manifest". Bpcn错误,求解!!!