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_DRIVERKEY_NAME (Structures)
 
.
Summary
Used with DeviceIoControl and IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME to get the "Driver Key Name" of a device on a USB Hub

C# Definition:

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
struct USB_NODE_CONNECTION_DRIVERKEY_NAME
{
   public int ConnectionIndex;
   public int ActualLength;
   [MarshalAs(UnmanagedType.ByValTStr, SizeConst = BUFFER_SIZE)]
   public string DriverKeyName;
}

VB Definition:

Structure USB_NODE_CONNECTION_DRIVERKEY_NAME
   Public TODO
End Structure

User-Defined Field Types:

None.

Notes:

Identical to the USB_NODE_CONNECTION_NAME structure

typedef struct _USB_NODE_CONNECTION_DRIVERKEY_NAME {
   ULONG  ConnectionIndex;
   ULONG  ActualLength;
   WCHAR  DriverKeyName[1];
} USB_NODE_CONNECTION_DRIVERKEY_NAME, *PUSB_NODE_CONNECTION_DRIVERKEY_NAME;

Documentation

Example:

// Open a handle to the Hub device
IntPtr h = CreateFile(PortHubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero);
if (h.ToInt32() != INVALID_HANDLE_VALUE)
{
   int nBytesReturned;

   // Get the Driver Key Name
   USB_NODE_CONNECTION_DRIVERKEY_NAME DriverKey = new USB_NODE_CONNECTION_DRIVERKEY_NAME();
   DriverKey.ConnectionIndex = PortPortNumber;
   int nBytes = Marshal.SizeOf(DriverKey);
   IntPtr ptrDriverKey = Marshal.AllocHGlobal(nBytes);
   Marshal.StructureToPtr(DriverKey, ptrDriverKey, true);

   // Use an IOCTL call to request the Driver Key Name
   if (DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME, ptrDriverKey, nBytes, ptrDriverKey, nBytes, out nBytesReturned, IntPtr.Zero))
   {
     DriverKey = (USB_NODE_CONNECTION_DRIVERKEY_NAME)Marshal.PtrToStructure(ptrDriverKey, typeof(USB_NODE_CONNECTION_DRIVERKEY_NAME));
     string DeviceDriverKey = DriverKey.DriverKeyName;

   }
   Marshal.FreeHGlobal(ptrDriverKey);
   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
Edit This Page
Find References
Show Printable Version
Revisions