基本介紹
結構體信息,定義,使用,示例代碼,
結構體信息
The IP_ADAPTER_INFO structure contains information about a particular network adapter on the local computer.
定義
#define MAX_ADAPTER_NAME_LENGTH 256#define MAX_ADAPTER_DESCRIPTION_LENGTH 128#define MAX_ADAPTER_ADDRESS_LENGTH 8typedef struct _IP_ADAPTER_INFO { struct _IP_ADAPTER_INFO* Next;//指向鍊表中下一個適配器信息的指針 DWORD ComboIndex;//預留值 char AdapterName[MAX_ADAPTER_NAME_LENGTH + 4];//適配器名稱 char Description[MAX_ADAPTER_DESCRIPTION_LENGTH + 4];//適配器描述 UINT AddressLength;//適配器硬體地址以位元組計算的長度 BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH];//硬體地址以BYTE數組所表示 DWORD Index;//適配器索引 UINT Type;//適配器類型 UINT DhcpEnabled;//指定這個適配器是否開啟DHCP PIP_ADDR_STRING CurrentIpAddress;//預留值 IP_ADDR_STRING IpAddressList;//該適配器的IPv4地址鍊表 IP_ADDR_STRING GatewayList;//該適配器的網關IPv4地址鍊表 IP_ADDR_STRING DhcpServer;//該適配器的DHCP伺服器的IPv4 地址鍊表 BOOL HaveWins; IP_ADDR_STRING PrimaryWinsServer; IP_ADDR_STRING SecondaryWinsServer; time_t LeaseObtained; time_t LeaseExpires;} IP_ADAPTER_INFO,*PIP_ADAPTER_INFO;
使用
ADAPTER_INFO structure is limited to IPv4 information about a particular network adapter on the local computer. The IP_ADAPTER_INFO structure is retrieved by calling the GetAdaptersInfo function.
結構體ADAPTER_INFO只限制於獲取本地計算機網路適配器的IPv4信息,該結構體通過調用GetAdaptersInfo函式獲取值。
其中,適配器類型Type欄位定義了已獲支持的適配器類型如下:
常數 | 數值 | 說明 |
MIB_IF_TYPE_ETHERNET | 6 | 乙太網適配器 |
MIB_IF_TYPE_FDDI | 15 | FDDI(光纖分布數據接口)適配器 |
MIB_IF_TYPE_LOOPBACK | 24 | Loopback適配器 |
MIB_IF_TYPE_OTHER | 1 | 其他類型的適配器 |
MIB_IF_TYPE_PPP | 23 | PPP適配器 |
MIB_IF_TYPE_SLIP | 28 | Slip適配器 |
MIB_IF_TYPE_TOKENRING | 9 | 令牌環適配器 |
示例代碼
// It is possible for an adapter to have multiple
// IPv4 addresses, gateways, and secondary WINS servers
// assigned to the adapter.
// Note that this sample code only prints out the