1. Tomáš Podzimek
  2. PowerBuilder
  3. Thursday, 22 June 2023 12:50 PM UTC

Hi,

Is there a way to get a list of available COM ports with their names - like in a Device Manager?

I've only found some C# solutions. I can read it from the registry

HKEY_LOCAL_MACHINE\hardware\devicemap\serialcomm

but there are no names, just a plain list.

Any help would be appreciated.

Tomáš

Accepted Answer
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 22 June 2023 13:26 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi, Tomáš -

You should be able to find this information using Windows Managment Instrumentation (WMI). Here's a link to two example applications in CodeXchange that utilize WMI:

https://community.appeon.com/index.php/codeexchange/powerbuilder/281-wmi-windows-management-instrumentation-class-properties-inspector#338

One app is a general-purpose WMI Class inspector, the other shows how you can easily obtain information about the requested properties of a particular WMI class.

I suggest you see if the Win32_SerialPortSetting class provides you with the information you are seeking.

Best regards, John

Comment
  1. Tomáš Podzimek
  2. Thursday, 22 June 2023 13:30 PM UTC
Hi John,

This looks promising. I will give it a try.

Regards,

Tomáš
  1. Helpful
  1. John Fauss
  2. Friday, 23 June 2023 01:32 AM UTC
I think you will find the Win32_SerialPort WMI class (as Roland has pointed out) will produce results that are more in line with your needs. Good luck!
  1. Helpful
  1. Tomáš Podzimek
  2. Friday, 23 June 2023 08:56 AM UTC
It turns out that Win32_SerialPort doesn't work well with virtual COM ports of USB connected devices.

I had to use this googled select:

SELECT * FROM Win32_PnPEntity WHERE Caption like '%(COM%'

for ExecQuery.

But still, thank you very much for your code, it was really helpful. Now I can make it work.



Regards,

Tomáš
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Thursday, 22 June 2023 13:35 PM UTC
  2. PowerBuilder
  3. # 1
Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.