如何获得本机子网掩码?

解决方案 »

  1.   

    GetIpAddrTable();原 型:
    DWORD GetIpAddrTable
    (
        PMIB_IPADDRTABLE pIpAddrTable,
       //buffer for mapping table
        PULONG pdwSize,//size of buffer
        BOOL bOrder       //sort the table 
    );Requirements:Windows NT/2000/XP: Included in Windows NT 4.0 SP4; Windows 2000; Windows XP Pro; and Windows .NET Server.Windows 95/98/Me: Included in Windows 98 and later.Header: Declared in Iphlpapi.h.Library: Use Iphlpapi.lib.
    返回值示例:pIpAddrTable->
        dwNumEntries = 2    table[0].dwAddr = 0x58ca09c0//192.9.202.88   
                      dwMask = 0xffffff//255.255.255.0  
                      dwBCastAddr = 0x1//1.0.0.0        
                      dwIndex = 0x2
                      dwReasmSize = 0xffff
                      wType = 0x23    table[1].dwAddr = 0x100007f//127.0.0.1      
                      dwMask = 0xff//255.0.0.0      
                      dwBCastAddr = 0x1//1.0.0.0        
                      dwIndex = 0x1
                      dwReasmSize = 0xffff
                      wType = 0x23
      

  2.   

    http://www.zdnet.com.cn/i/developer/story/200208/39046680/code_1.htm
      

  3.   

    http://www.zdnet.com.cn/i/developer/story/200208/39046680/code_1.htm
      

  4.   

    用WinpCap,见下面文章,它的例子列出了本机的子网掩码
    http://www.sangel.net/article/list.asp?id=246