internal static FixedInfo GetFixedInfo()
        {
            uint          size      = 0;
            SafeLocalFree buffer    = null;
            FixedInfo     fixedInfo = new FixedInfo();

            //first we need to get the size of the buffer
            uint result = UnsafeNetInfoNativeMethods.GetNetworkParams(SafeLocalFree.Zero, ref size);

            while (result == IpHelperErrors.ErrorBufferOverflow)
            {
                try {
                    //now we allocate the buffer and read the network parameters.
                    buffer = SafeLocalFree.LocalAlloc((int)size);
                    result = UnsafeNetInfoNativeMethods.GetNetworkParams(buffer, ref size);
                    if (result == IpHelperErrors.Success)
                    {
                        fixedInfo = new FixedInfo((FIXED_INFO)Marshal.PtrToStructure(buffer.DangerousGetHandle(), typeof(FIXED_INFO)));
                    }
                }
                finally {
                    if (buffer != null)
                    {
                        buffer.Close();
                    }
                }
            }

            //if the result include there being no information, we'll still throw
            if (result != IpHelperErrors.Success)
            {
                throw new NetworkInformationException((int)result);
            }
            return(fixedInfo);
        }
        internal static System.Net.NetworkInformation.FixedInfo GetFixedInfo()
        {
            uint          pOutBufLen = 0;
            SafeLocalFree pFixedInfo = null;

            System.Net.NetworkInformation.FixedInfo info = new System.Net.NetworkInformation.FixedInfo();
            uint networkParams = UnsafeNetInfoNativeMethods.GetNetworkParams(SafeLocalFree.Zero, ref pOutBufLen);

            while (networkParams == 0x6f)
            {
                try
                {
                    pFixedInfo    = SafeLocalFree.LocalAlloc((int)pOutBufLen);
                    networkParams = UnsafeNetInfoNativeMethods.GetNetworkParams(pFixedInfo, ref pOutBufLen);
                    if (networkParams == 0)
                    {
                        info = new System.Net.NetworkInformation.FixedInfo((FIXED_INFO)Marshal.PtrToStructure(pFixedInfo.DangerousGetHandle(), typeof(FIXED_INFO)));
                    }
                    continue;
                }
                finally
                {
                    if (pFixedInfo != null)
                    {
                        pFixedInfo.Close();
                    }
                }
            }
            if (networkParams != 0)
            {
                throw new NetworkInformationException((int)networkParams);
            }
            return(info);
        }