public static IPAddressInformationCollection Win32FromAnycast(IntPtr ptr) { IPAddressInformationImplCollection ipaddressInformationImplCollection = new IPAddressInformationImplCollection(false); IntPtr intPtr = ptr; while (intPtr != IntPtr.Zero) { Win32_IP_ADAPTER_ANYCAST_ADDRESS win32_IP_ADAPTER_ANYCAST_ADDRESS = (Win32_IP_ADAPTER_ANYCAST_ADDRESS)Marshal.PtrToStructure(intPtr, typeof(Win32_IP_ADAPTER_ANYCAST_ADDRESS)); ipaddressInformationImplCollection.Add(new IPAddressInformationImpl(win32_IP_ADAPTER_ANYCAST_ADDRESS.Address.GetIPAddress(), win32_IP_ADAPTER_ANYCAST_ADDRESS.LengthFlags.IsDnsEligible, win32_IP_ADAPTER_ANYCAST_ADDRESS.LengthFlags.IsTransient)); intPtr = win32_IP_ADAPTER_ANYCAST_ADDRESS.Next; } ipaddressInformationImplCollection.is_readonly = true; return(ipaddressInformationImplCollection); }
public static IPAddressInformationCollection Win32FromAnycast(IntPtr ptr) { IPAddressInformationImplCollection c = new IPAddressInformationImplCollection(false); Win32_IP_ADAPTER_ANYCAST_ADDRESS a; for (IntPtr p = ptr; p != IntPtr.Zero; p = a.Next) { a = (Win32_IP_ADAPTER_ANYCAST_ADDRESS)Marshal.PtrToStructure(p, typeof(Win32_IP_ADAPTER_ANYCAST_ADDRESS)); c.Add(new IPAddressInformationImpl( a.Address.GetIPAddress(), a.LengthFlags.IsDnsEligible, a.LengthFlags.IsTransient)); } c.is_readonly = true; return(c); }