@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.
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 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.
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?
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.