是用网管软件吧!比如:NetManager

解决方案 »

  1.   

    是要所有的地址ping一下吧!
    要是在一个网段中倒是不多!
      

  2.   

    用WNetEnumResource()可以得到域下所有的机器名,然后可以用gethostbyname()去取各自的ip address。
    关于这两个函数的用法,请参见MSDN。
      

  3.   

    WNetEnumResource()之前要调用WNetOpenEnum(),gethostbyname()之前要调用WSAStartup()。
      

  4.   

    WNetEnumResource()之前要调用WNetOpenEnum();gethostbyname()之前要调用WSAStartup()。
      

  5.   

    To: pcman1990(pcman)
      用WNetEnumResource()该函数还要牵涉其它函数;
      能否给个例子
      

  6.   

    BYTE nr[2048];
    LPNETRESOURCE lpnr = (LPNETRESOURCE)nr;
    DWORD dwSize = sizeof(nr);
    HANDLE hRs;
    DWORD dwRn = WNetOpenEnum(RESOURCE_GLOBALNET,
     RESOURCETYPE_ANY,
     RESOURCEUSAGE_CONNECTABLE,
     lpnr, &hRs);
    DWORD   dwCount = 1;
    while (dwRn == NO_ERROR)
    {
        dwRn = WNetEnumResource(hRs, &dwCount, (LPNETRESOURCE)nr, &dwSize); 
        if(dwRn == NO_ERROR)
        {
            ......
            // 看一下NETRESOURCE数据结构就可以知道怎么取name了
        }
    }WNetCloseEnum(hRs);
      

  7.   

    thanks for pcman1990(pcman)
      试过后,立即给分!!!!!!!
      

  8.   

    To: pcman1990(pcman)
       为何执行WNetOpenEnum()不成功?
      

  9.   

    加上
    #include "Winnetwk.h"
      

  10.   

    http://www.vckbase.com/bbs/prime/viewprime.asp?id=158
      

  11.   

    用GetLastError()查一下是什么错。ERROR_NOT_CONTAINER 
      The lpNetResource parameter does not point to a container. 
    ERROR_INVALID_PARAMETER 
      Either the dwScope or dwType parameter is invalid, or there is a bad combination of parameters. 
    ERROR_NO_NETWORK 
      No network is present. 
    ERROR_EXTENDED_ERROR 
      A network-specific error occurred. To get a description of the error, use the WNetGetLastError function.