阅读:1523回复:1
参考老帖,仍然不能获取本地IP
这是以前帖中的一段代码
while(Oid == OID_GEN_NETWORK_LAYER_ADDRESSES) { // DbgPrint(\"=>OID_GEN_NETWORK_LAYER_ADDRESSES\\n\"); pAddrList = (PNETWORK_ADDRESS_LIST)NdisRequest->DATA.SET_INFORMATION.InformationBuffer; if (pAddrList->AddressCount <= 0) break; pAddr = (PNETWORK_ADDRESS)&pAddrList->Address[0]; if (pAddr->AddressType != NDIS_PROTOCOL_ID_TCP_IP) break; pIpAddr = (NETWORK_ADDRESS_IP UNALIGNED *)&pAddr->Address[0]; ipsec_local_ipaddr = pIpAddr->in_addr; // DbgPrint(\"OID_GEN_NETWORK_LAYER_ADDRESSES = %.8X\\n\",ipsec_local_ipaddr); break; }; 每次获取的pAddrList->AddressCount = 0, pAddr->AddressType = NDIS_PROTOCOL_ID_DEFAULT (不清楚这个类型是什么意思?) 而且我看WDK里面讲NETWORK_ADDRESS_LIST: AddressType,This member is only valid if the AddressCount member is set to zero. NETWORK_ADDRESS: This member is only valid if the AddressCount member in the NETWORK_ADDRESS_LIST structure is set to a nonzero value. 不明白上面代码为什么要 pAddr = (PNETWORK_ADDRESS)&pAddrList->Address[0] if (pAddr->AddressType != NDIS_PROTOCOL_ID_TCP_IP) break; 我尝试过直接用pAddrList->AddressType,但是结果仍然是NDIS_PROTOCOL_ID_DEFAULT ,就是不能获取IP,这个请求是我自己发的 求教高手解答 |
|
沙发#
发布于:2008-11-21 16:09
补充,This OID notifies underlying miniport and other layered drivers about the l
ist of network-layer addresses that are associated with bound instances. A b ound instance is the binding between the calling transport and a driver set up by a call to NdisOpenAdapter. Transports use TRANSPORT_ADDRESS and TA_ADD RESS structures to notify underlying miniport and other layered drivers abou t the list of network-layer addresses. 除此之外,还有没有查IP的方法 ,求教························ |
|