[DllImport("iphlpapi.dll", CharSet=CharSet.Ansi)]
public static extern int GetNetworkParams(IntPtr pFixedInfo, ref UInt32 pBufOutLen);
TODO
None.
Use System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().
Note that ScopeId is renamed to DhcpScopeName and EnableProxy is renamed to IsWinsProxy.
Returns a FIXED_INFO struct.
Please add some!
int infoLen = Marshal.SizeOf(typeof(FIXED_INFO));
int ret;
while (true)
{
infoPtr = Marshal.AllocHGlobal(Convert.ToInt32(infoLen));
ret = GetNetworkParams(infoPtr, ref infoLen);
if (ret == ERROR_BUFFER_OVERFLOW)
{
//try again w/ bigger buffer:
Marshal.FreeHGlobal(infoPtr);
continue;
}
if (ret == ERROR_SUCCESS)
break;
throw new ApplicationException("An error occurred while fetching adapter information.", new Win32Exception(Convert.ToInt32(ret)));
}
FIXED_INFO info = (FIXED_INFO)Marshal.PtrToStructure(infoPtr, typeof(FIXED_INFO));