> For the complete documentation index, see [llms.txt](https://pinvokeisalive.gitbook.io/pinvoke/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pinvokeisalive.gitbook.io/pinvoke/directory/structures/usb_node_connection_driverkey_name.md).

# USB\_NODE\_CONNECTION\_DRIVERKEY\_NAME

### C# Definition:

```cs
[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:

```cs
Structure USB_NODE_CONNECTION_DRIVERKEY_NAME 
   Public TODO
End Structure
```

### Notes:

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

### Example:

```cs
// 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);
}
Used with DeviceIoControl and [USB_NODE_CONNECTION_DRIVERKEY_NAME] to get the "Driver Key Name" from a device on a USB Hub5/15/2017 4:52:43 AM - -94.229.131.27
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pinvokeisalive.gitbook.io/pinvoke/directory/structures/usb_node_connection_driverkey_name.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
