WinUsb_QueryPipe function

The WinUsb_QueryPipe function retrieves information about the specified endpoint and the associated pipe for an interface.


BOOL __stdcall WinUsb_QueryPipe(
  _In_  WINUSB_INTERFACE_HANDLE  InterfaceHandle,
  _In_  UCHAR                    AlternateInterfaceNumber,
  _In_  UCHAR                    PipeIndex,


InterfaceHandle [in]

An opaque handle to an interface that contains the endpoint with which the pipe is associated.

To query the pipe associated with an endpoint in the first interface, use the handle returned by WinUsb_Initialize. For all other interfaces, use the handle to the target interface, retrieved by WinUsb_GetAssociatedInterface.

AlternateInterfaceNumber [in]

A value that specifies the alternate interface to return the information for.

PipeIndex [in]

A value that specifies the pipe to return information about. This value is not the same as the bEndpointAddress field in the endpoint descriptor. A PipeIndex value of 0 signifies the first endpoint that is associated with the interface, a value of 1 signifies the second endpoint, and so on. PipeIndex must be less than the value in the bNumEndpoints field of the interface descriptor.

PipeInformation [out]

A pointer, on output, to a caller-allocated WINUSB_PIPE_INFORMATION structure that contains pipe information.

Return value

WinUsb_QueryPipe returns TRUE if the operation succeeds. Otherwise, this function returns FALSE, and the caller can retrieve the logged error by calling GetLastError.

GetLastError can return the following error code.

Return codeDescription

The caller passed NULL in the InterfaceHandle parameter.


The caller passed NULL in the PipeInformation parameter; interface descriptor could not be found for the handle specified in InterfaceHandle.


The value passed in the PipeIndex parameter is greater than the bNumEndpoints value of the interface descriptor; endpoint descriptor could not be found for the specified interface.



The WinUsb_QueryPipe function does not retrieve information about the control pipe.

Each interface on the USB device can have multiple endpoints. To communicate with each of these endpoints, the bus driver creates pipes for each endpoint on the interface. The pipe indices are zero-based. Therefore for n number of endpoints, the pipes' indices are set from n-1. WinUsb_QueryPipe parses the configuration descriptor to get the interface specified by the caller. It searches the interface descriptor for the endpoint descriptor associated with the caller-specified pipe. If the endpoint is found, the function populates the caller-allocated WINUSB_PIPE_INFORMATION structure with information from the endpoint descriptor.


Target platform



Winusb.h (include Winusb.h)





See also

WinUSB Functions



Send comments about this topic to Microsoft