This section describes the steps you need to carry in order to enumerate the serial devices installed on the computer.
Initialize the SerialMonitor object, as described in the this tutorial.
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;
Get the value of the Count property:
long Count = pDeviceCollection->Count;
uint Count = devices.Count;
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)
{
// ...
}