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

USB_NODE_CONNECTION_INFORMATION_EX (Structures)
 
.
Summary
Retrieve information about a port connection on a USB Hub

C# Definition:

[StructLayout(LayoutKind.Sequential, Pack=1)]
struct USB_NODE_CONNECTION_INFORMATION_EX
{
   public int ConnectionIndex;
   public USB_DEVICE_DESCRIPTOR DeviceDescriptor;
   public byte CurrentConfigurationValue;
   public byte Speed;
   public byte DeviceIsHub;
   public short DeviceAddress;
   public int NumberOfOpenPipes;
   public int ConnectionStatus;
   //public IntPtr PipeList;
}

VB Definition:

Structure USB_NODE_CONNECTION_INFORMATION_EX
   Public TODO
End Structure

User-Defined Field Types:

None.

Notes:

The use of a zero-length array at the end of the structure makes using this in C#/VB.Net a bit tricky. You should allways allocate sufficient buffer space beyond the true size of the structure. The use of "pack=1" may be required to accurately find the "end" of the structure where the unmanaged buffer starts.

typedef struct _USB_NODE_CONNECTION_INFORMATION_EX {
   ULONG  ConnectionIndex;
   USB_DEVICE_DESCRIPTOR  DeviceDescriptor;
   UCHAR  CurrentConfigurationValue;
   UCHAR  Speed;
   BOOLEAN  DeviceIsHub;
   USHORT  DeviceAddress;
   ULONG  NumberOfOpenPipes;
   USB_CONNECTION_STATUS  ConnectionStatus;
   USB_PIPE_INFO  PipeList[0];
} USB_NODE_CONNECTION_INFORMATION_EX, *PUSB_NODE_CONNECTION_INFORMATION_EX;

Documentation

Example:

// Open a handle to the Hub device
IntPtr h = CreateFile(HubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero);
if (h.ToInt32() != INVALID_HANDLE_VALUE)
{
   int nBytes = Marshal.SizeOf(typeof(USB_NODE_CONNECTION_INFORMATION_EX));
   IntPtr ptrNodeConnection = Marshal.AllocHGlobal(nBytes);

   // loop thru all of the ports on the hub
   // BTW: Ports are numbered starting at 1
   for (int i = 1; i <= HubPortCount; i++)
   {
     int nBytesReturned;
     USB_NODE_CONNECTION_INFORMATION_EX NodeConnection = new USB_NODE_CONNECTION_INFORMATION_EX();
     NodeConnection.ConnectionIndex = i;
     Marshal.StructureToPtr(NodeConnection, ptrNodeConnection, true);

     if (DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX, ptrNodeConnection, nBytes, ptrNodeConnection, nBytes, out nBytesReturned, IntPtr.Zero))
     {
       NodeConnection = (USB_NODE_CONNECTION_INFORMATION_EX)Marshal.PtrToStructure(ptrNodeConnection, typeof(USB_NODE_CONNECTION_INFORMATION_EX));
       // do something here...
     }
   }
   Marshal.FreeHGlobal(ptrNodeConnection);
   CloseHandle(h);
}

Please edit this page!

Do you have...

  • helpful tips?
  • corrections to the existing content?
  • alternate definitions?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing any supporting types needed.

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