Serial Port Monitoring Control - ActiveX Component Library for RS232 Data Monitoring, API for Software Developers
Docs

How To Enumerate Serial Devices

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

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

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

    IDeviceCollectionPtr pDeviceCollection = pSerialMonitor->Devices;
    
    DeviceCollection devices = sm.Devices;
    
  3. Get the value of the Count property:

    long Count = pDeviceCollection->Count;
    
    uint Count = devices.Count;
    
  4. Cycle through all items of the collection:

    for (long i = 0; i < Count; ++i)
    {
        IDevicePtr pDevice = pDeviceCollection->Item[CComVariant {i}];
        // ...
    } 
    
    foreach (var device in devices)
    {
        // ...
    }