简体   繁体   English

如何在C#中读取USB闪存驱动器的超高速或高速

[英]How to read Superspeed or Highspeed of a USB flash drive in C#

I have found this question and answer within this site here: Detect if device is using USB 3.0 but when I ran the program, the result never returned a SuperSpeed connection. 我在这里找到了这个问题和答案: 检测设备是否使用USB 3.0,但是当我运行程序时,结果从未返回SuperSpeed连接。 I plugged in the USB3.0 flash drive into the USB 3 port so it's supposed to return SuperSpeed to me. 我将USB3.0闪存盘插入USB 3端口,因此它应该将SuperSpeed返回给我。

The complete code is the following piece from <@Sani Huttunen> 完整的代码是<@Sani Huttunen>的以下部分

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.ComponentModel;
using System.Diagnostics;

class MainCode
{
private static void Main(string[] args)
{

    var hostCtrls = USB.GetHostControllers();

    foreach (var hostCtrl in hostCtrls)
    {
        var hub = hostCtrl.GetRootHub();
        foreach (var port in hub.GetPorts())
        {
            if (port.IsDeviceConnected && !port.IsHub)
            {
                var device = port.GetDevice();
                Console.WriteLine("Serial: " + device.DeviceSerialNumber);
                Console.WriteLine("Speed:  " + port.Speed);
                Console.WriteLine("Port:   " + device.PortNumber + Environment.NewLine);
            }
        }
    }
}
}

and the library from here: http://read.pudn.com/downloads105/sourcecode/windows/vxd/432626/USBLib/USB.cs__.htm 和来自这里的图书馆: http//read.pudn.com/downloads105/sourcecode/windows/vxd/432626/USBLib/USB.cs__.htm

In the library, I see that they only have: 在图书馆,我看到他们只有:

enum USB_DEVICE_SPEED : byte
    {
        UsbLowSpeed,
        UsbFullSpeed,
        UsbHighSpeed,

    }

The question here is how to read the correct speed of the USB flash drive. 这里的问题是如何读取USB闪存驱动器的正确速度。 With the above code and the library, my USB 3.0 flash drive in the USB 3 port always returns Highspeed instead of Superspeed. 使用上面的代码和库,USB 3端口中的USB 3.0闪存驱动器始终返回Highspeed而不是Superspeed。

Due to backward compatibility, SuperSpeed/USB3 devices are reported back as HighSpeed/USB2, if you really need to know if the device is Super speed, you need to use: 由于向后兼容性,SuperSpeed / USB3设备被报告为HighSpeed / USB2,如果你真的需要知道设备是否超速,你需要使用:

IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX_V2 IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX_V2

https://msdn.microsoft.com/en-us/library/windows/hardware/hh450861(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/hardware/hh450861(v=vs.85).aspx

I hope this helps 我希望这有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM