WindowsSerialPortsMBS Returns No Ports if OnlyPresent is True

@Christian_Schmitz have five active COM ports. If I set OnlyPresent to False in the WindowsSerialPortsMBS Constructor, WindowsSerialPortsMBS returns 20 ports (not surprising). If I set it to True, however, it returns no ports.

Is this a bug and if so, has it been fixed in new versions of MBS plugins?

MBS 214, Xojo 2021r2.1

Feel free to try the new plugin. The WindowsSerialPortsMBS function queries the registry entries and sounds like you have some problem there. Never saw anyone with 52 COM ports.

Also check newer SerialPortMBS class. It also has a function to query ports.

The result is the same with MBS 224. If I set OnlyPresent to False in the Constructor, WindowsSerialPortsMBS returns 20 ports; if I set it to True, it returns no ports.

I did, and it has the same bug.

I don’t think I have registry problems. Device Manager reports the ports correctly, Win32 API calls report the ports correctly, and I can talk to the ports using Xojo’s classes and yours.

I don’t have 52 COM ports. The plugin reports 20 ports if “PresentOnly” is set to false. This is not surprising because I work with hardware that has five ports, and in the course of development I turn it on and off and plug/unplug it a lot, and I’m working with multiple instances of that hardware. So some “stale” registry entries are to be expected.

What is not expected is for the plugin to report no ports at all when “PresentOnly” is set to True, because I do indeed have five ports present and working.

I am using this class but I also need WindowsSerialPortsMBS to work so I can correlate the COM ports with their USB devices.

Could it be that PresentOnly means “Open” ?

I am sorry, if the function doesn’t do what you need.

We call SetupDiGetClassDevs internally.
The DIGCF_PRESENT flag there means: Return only devices that are currently present in a system.

So the class may tell you more devices, than you have, but maybe you can filter the ports on your system with those given by SerialPortMBS List function.

That is what I understood, it’s very clear. This is what I want - the devices currently present in my system. It doesn’t seem to work, though, because I have five devices present (they are shown in Device Manager, I can communicate with them using any terminal program like TeraTerm, etc) but the function returns zero devices.

It’s not a question of the whether the function doesn’t “do what I need” - I believe it would do exactly what I need if it worked. How can it return zero devices when I plainly have five devices currently present and active?

Maybe I should have used this screenshot, as it shows the real issue:

I believe the xojo serialconnection has a way to see the currently (wired) connected devices.

With the SerialDevice class:

Curious what WindowsSerialPortsMBS.QueryComDevices returns?

1 Like

It returns the five COM port names, as expected.

1 Like

Yes it does, but it returns no information useful for enumerating devices. The MBS function, if it worked, would give me USB PID/VID etc.


1 Like

Please join the output of both classes.
Sorry, but I can’t find an issue here.





Here is the output of the Win32 declares I have been using:

This code was written by @Chris_Carter some years ago and can be downloaded here:


One more question for my thinking cap… are these serial devices singular or composite? i.e. Do they have one or more than one serial port per USB device? Possibly irrelevant, but might affect how the device information set returned by SetupDiGetClassDevs needs to be enumerated.

Both. One is an FTDI FT4232H 4-port composite, and one is an FT231X single-port device.