Share via


An application can use IOCTL_NDIS_QUERY_GLOBAL_STATS to obtain information from a network adapter. The application passes IOCTL_NDIS_QUERY_GLOBAL_STATS, along with an Object Identifier(OID), in the DeviceIoControl function.


IOCTL_NDIS_QUERY_GLOBAL_STATS directs NDIS to use the specified OID to obtain information from the specified network adapter.

BOOL DeviceIoControl(
 IN HANDLE hDevice,
 IN DWORD dwIoControlCode,
 IN LPVOID lpInBuffer,
 IN DWORD nInBufferSize,
 OUT LPVOID lpOutBuffer,
 IN DWORD nOutBufferSize,
 OUT LPDWORD lpBytesReturned,


  • hDevice
    Handle to the network adapter on which to obtain information. To retrieve this handle, use the CreateFile function.

  • dwIoControlCode

  • lpInBuffer
    Pointer to a buffer that contains the query OID that NDIS should use.

  • nInBufferSize
    Specifies the size, in bytes, of the query OID at lpInBuffer.

  • lpOutBuffer
    Pointer to a buffer that receives the data that was requested by the query OID at lpInBuffer.

  • nOutBufferSize
    Specifies the size, in bytes, of the buffer that the caller allocated for lpOutBuffer.

  • lpBytesReturned
    Pointer to a variable that receives the actual size, in bytes, of the data stored at lpOutBuffer.

  • lpOverlapped
    Specifies NULL if the query is to be performed synchronously or can be a pointer to a valid OVERLAPPED structure if the query is to be performed asynchronously. Whether the query is synchronous or asynchronous depends on whether the handle in hDevice was created with the FILE_FLAG_OVERLAPPED flag, which indicates overlapped (or asynchronous) operation. Both FILE_FLAG_OVERLAPPED and OVERLAPPED are described in the Microsoft Windows SDK documentation.

Return Values

If the query succeeds, DeviceIoControl returns a nonzero value.

If the query fails, DeviceIoControl returns zero. To get extended error information, call GetLastError.


Defined in ntddndis.h. Include ntddndis.h.


This IOCTL will be deprecated in later operating system releases. You should use WMI interfaces to query miniport driver information. For more information see, NDIS Support for WMI.

An application can use IOCTL_NDIS_QUERY_GLOBAL_STATS with any query OID that is supported by the network adapter and the adapter's miniport driver.

Before an application can use IOCTL_NDIS_QUERY_GLOBAL_STATS, it must call the CreateFile function to open a handle to the network adapter. In this CreateFile call, the application passes a pointer to a null-terminated string that specifies the name of the device that NDIS registered. For NT-based operating systems, the application can retrieve the name from the ServiceName value of the HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\NetworkCards\Nnn key in the registry, where is the string for the adapter's instance number. The string should be of the form "**\\.\**Xxx", where Xxx is the string for the adapter's service name. The application can use the following registry functions to access the registry:

  • RegOpenKeyEx to open a key.

  • RegEnumKeyEx to enumerate the subkeys of a given key.

  • RegQueryValueEx to retrieve detailed data about a particular subkey.

  • RegCloseKey to close a key.

For more information about DeviceIoControl, CreateFile, GetLastError, and the registry functions, see the Windows SDK documentation.

For Windows 2000 and later versions, use the interface name to open the device. To get the interface name, enumerate the GUID_NDIS_LAN_CLASS device interfaces by calling the SetupDiEnumDeviceInterfaces function. For information about enumerating device interfaces, see Device Information Sets.

Windows 98/Me do not support IOCTL_NDIS_QUERY_GLOBAL_STATS.



Send comments about this topic to Microsoft