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); }
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; }