GetIfTable2Ex function

The GetIfTable2Ex function retrieves the MIB-II interface table, given a level of interface information to retrieve.


  _Out_ PMIB_IF_TABLE2     *Table


  • Level [in]
    The level of interface information to retrieve. This parameter can be one of the values from the MIB_IF_TABLE_LEVEL enumeration.

  • Table [out]
    A pointer to a buffer that receives the table of interfaces in a MIB_IF_TABLE2 structure.

Return value

GetIfTable2Ex returns STATUS_SUCCESS if the function succeeds.

If the function fails, GetIfTable2Ex returns one of the following error codes:

Return code Description

An invalid parameter was passed to the function. This error is returned if an illegal value was passed in the Level parameter.


Insufficient memory resources are available to complete the operation.


Use the FormatMessage function to obtain the message string for the returned error.


The GetIfTable2Ex function enumerates the logical and physical interfaces on a local computer and returns this information in a MIB_IF_TABLE2 structure.

Your driver can use a similar function, GetIfTable2, to retrieve interfaces, but GetIfTable2 does not enable your driver tospecify the level of interfaces to return. A call to the GetIfTable2Ex function with the Level parameter set to MibIfTableNormal retrieves the same results as calling the GetIfTable2 function.

GetIfTable2Ex returns interfaces in a MIB_IF_TABLE2 structure in the buffer that the Table parameter points to. The MIB_IF_TABLE2 structure contains an interface count and an array of MIB_IF_ROW2 structures for each interface. GetIfTable2 allocates mmory for the MIB_IF_TABLE2 structure and the MIB_IF_ROW2 entries in this structure. When these returned structures are no longer required, your driver should free the memory by calling FreeMibTable.

All interfaces, including NDIS intermediate driver interfaces and NDIS filter driver interfaces, are returned for either of the possible values for the Level parameter. The setting for the Level parameter affects how statistics and state members of the MIB_IF_ROW2 structure in the MIB_IF_TABLE2 structure that is pointed to by the Table parameter for the interface are returned. For example, a network interface card (NIC) has an NDIS miniport driver. An NDIS intermediate driver can be installed to interface between upper-level protocol drivers and NDIS miniport drivers. An NDIS filter driver can be attached on top of the NDIS intermediate driver. Assume that the NIC reports the MediaConnectState member of the MIB_IF_ROW2 structure as MediaConnectStateConnected, but the NDIS filter driver modifies the state and reports the state as MediaConnectStateDisconnected. When the interface information is queried with Level parameter set to MibIfTableNormal, the state at the top of the filter stack (MediaConnectStateDisconnected) is reported. When the interface is queried with the Level parameter set to MibIfTableRaw, the state at the interface level directly (MediaConnectStateConnected) is returned.

Note that the returned MIB_IF_TABLE2 structure that the Table parameter points to might contain padding for alignment between the NumEntries member and the first MIB_IF_ROW2 array entry in the Table member of the MIB_IF_TABLE2 structure. Padding for alignment might also be present between the MIB_IF_ROW2 array entries. Any access to a MIB_IF_ROW2 array entry should assume padding may exist.


Target platform



Available in Windows Vista and later versions of the Windows operating systems.


Netioapi.h (include Netioapi.h)





See also






Send comments about this topic to Microsoft