Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

GetNetworkParams (iphlpapi)
 
.
Summary
Retrieve network parameters for the local computer

C# Signature:

[DllImport("iphlpapi.dll", CharSet=CharSet.Ansi)]
public static extern int GetNetworkParams(IntPtr pFixedInfo, ref UInt32 pBufOutLen);

VB Signature:

TODO

User-Defined Types:

None.

Alternative Managed API:

Use System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().

Note that ScopeId is renamed to DhcpScopeName and EnableProxy is renamed to IsWinsProxy.

Notes:

Returns a FIXED_INFO struct.

Tips & Tricks:

Please add some!

Sample Code:

IntPtr infoPtr = IntPtr.Zero;

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

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Find References
Show Printable Version
Revisions