Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than iphlpapi, prefix the name with the module name and a period.
GetIfTable (iphlpapi)
.
C# Signature:
/// <summary>
/// Get the information about the current Network adapter in the system
/// </summary>
/// <param name="pIfTable">A pointer to a buffer that receives the interface table as a MIB_IFTABLE structure</param>
/// <param name="pdwSize">
/// size of buffer
/// On input, specifies the size in bytes of the buffer pointed to by the pIfTable parameter.
/// On output, if the buffer is not large enough to hold the returned interface table,
/// the function sets this parameter equal to the required buffer size in bytes
/// </param>
/// <param name="bOrder">
/// sort the table by index
/// A Boolean value that specifies whether the returned interface table should be sorted
/// in ascending order by interface index. If this parameter is TRUE, the table is sorted.
/// </param>
/// <returns>
/// If the function succeeds, the return value is
/// NO_ERROR = 0
/// ERROR_INSUFFICIENT_BUFFER = 122
/// </returns>
[DllImport("Iphlpapi.dll", SetLastError=true)]
public static extern uint GetIfTable(IntPtr pIfTable, ref uint pdwSize, bool bOrder);
VB Signature:
Declare Function GetIfTable Lib "iphlpapi.dll" (TODO) As TODO
/// <summary>
/// Wrapper to unmanaged code. to use all in C# declarations
/// </summary>
public class IPHelperWrapper
{
#region fields
/// <summary>
/// MIB_IFROW Declaration
/// </summary>
protected static IPHelperTraslation.MIB_IFROW netWorkInfoBlock;
/// <summary>
/// MIB_IFROW structure array. Content the active networks connection
/// </summary>
public static IPHelperTraslation.MIB_IFROW[] mRows;
#endregion
#region Wrapper Method
/// <summary>
/// Get the Active Interface networks in an array of MIB_IFROW.
/// each network comes in a row. See MIB_IFROW in IPHelper Traslation for more
/// information about MIB_IFROW
/// </summary>
/// <returns>
/// A array of MIB_IFROW structure
/// </returns>
public static IPHelperTraslation.MIB_IFROW[] GetNetworkInterfaceBlock()
{
uint size = 0;
IPHelperTraslation.GetIfTable(IntPtr.Zero, ref size, false);
IntPtr buf = Marshal.AllocHGlobal((int)size);
IPHelperTraslation.GetIfTable(buf, ref size, false);
int numEntries = Marshal.ReadInt32(buf);
int pRows = 4 + (int)buf;
mRows = new IPHelperTraslation.MIB_IFROW[numEntries];
for (int i = 0; i < numEntries; i++)
{
mRows[i] = (IPHelperTraslation.MIB_IFROW)Marshal.PtrToStructure((IntPtr)pRows, typeof(IPHelperTraslation.MIB_IFROW));
pRows += Marshal.SizeOf(typeof(IPHelperTraslation.MIB_IFROW));
}
Marshal.FreeHGlobal(buf);
return mRows;
}
#endregion
}
P/ invoque for GetIfTable iphlpapi function. Only C# example. You need also a MIB_IFROW structure
6/5/2014 9:38:56 PM - -188.192.82.156
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).