USB Monitoring Control - TODO
Docs

How to Enumerate USB Devices

This section describes the steps you need to carry in order to enumerate the USB devices installed on the computer.

  1. Initialize the usbMonitor object, as described in the this tutorial.

  2. Obtain the pointer to the IDeviceCollection interface of the USB device collection object by taking the value of the IUsbMonitor.Devices property:

    CComPtr<IDeviceCollection> pDeviceCollection;
    pUsbMonitor->get_Devices(&pDeviceCollection);
    
    DeviceCollection devices = sm.Devices;
    
  3. Get the value of the IDeviceCollection.Count property:

    ULONG Count;
    pDeviceCollection->get_Count(&Count);
    
    uint Count = devices.Count;
    
  4. Cycle through all items of the collection:

    for (int i = 0; i < Count; ++i)
    {
        CComPtr<IDevice> pDevice;
        pDeviceCollection->get_Item(CComVariant(i), &pDevice);
        // ...
    }
    
    for (int i = 0; i < Count; ++i)
    {
        Device device = devices[i];
        // ...
    }
    

    or

    foreach (var device in devices)
    {
        // ...
    }