Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 368297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:48:37+00:00 2026-05-12T13:48:37+00:00

I have some legacy code that provides a list of the available COM ports

  • 0

I have some legacy code that provides a list of the available COM ports on the PC by calling the EnumPorts() function and then filtering for the port names that start with “COM”.

For testing purposes it would be very useful if I could use this code with something like com0com, which provides pairs of virtual COM ports looped together as a null-modem.

However the com0com ports are not found by the EnumPorts() function (even without filtering for “COM”). HyperTerminal and SysInternals PortMon can both see them, so I’m sure it is installed correctly.

So is there some other Win32 function that provides a definitive list of available serial ports?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T13:48:37+00:00Added an answer on May 12, 2026 at 1:48 pm

    The EnumSerialPorts v1.20 suggested by Nick D uses nine different methods to list the serial ports! We’re certainly not short on choice, though the results seem to vary.

    To save others the trouble, I’ll list them here and indicate their success in finding the com0com ports on my PC (XP Pro SP2):

    1. CreateFile(“COM” + 1->255) as suggested by Wael Dalloul
      ✔ Found com0com ports, took 234ms.

    2. QueryDosDevice()
      ✔ Found com0com ports, took 0ms.

    3. GetDefaultCommConfig(“COM” + 1->255)
      ✔ Found com0com ports, took 235ms.

    4. “SetupAPI1” using calls to SETUPAPI.DLL
      ✔ Found com0com ports, also reported “friendly names”, took 15ms.

    5. “SetupAPI2” using calls to SETUPAPI.DLL
      ✘ Did not find com0com ports, reported “friendly names”, took 32ms.

    6. EnumPorts()
      ✘ Reported some non-COM ports, did not find com0com ports, took 15ms.

    7. Using WMI calls
      ✔ Found com0com ports, also reported “friendly names”, took 47ms.

    8. COM Database using calls to MSPORTS.DLL
      ✔/✘ Reported some non-COM ports, found com0com ports, took 16ms.

    9. Iterate over registry key HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM
      ✔ Found com0com ports, took 0ms. This is apparently what SysInternals PortMon uses.

    Based on those results I think the WMI method probably suits my requirements best as it is relatively fast and as a bonus it also gives the friendly names (e.g. “Communications Port (COM1)”, “com0com – serial port emulator”).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some legacy code with a legacy function that takes a filename as
I have some legacy code that was used to monitor my applications cpu,memory etc
I have some legacy C++ code that I am trying to understand a bit
We have some legacy ASP.NET code that detects if a request is secure, and
I have some legacy code that contains this typedef: typedef enum simple_op_enum { #define
I have some legacy code that uses Interlocked.Equals to compare values. The values may
Currently I have some legacy ASP.NET 2.0 code that uses the ASP Xml web
Ok, so I've got some legacy code from another company that I have to
I have come across some legacy code that has the following type of line:
We have some legacy code that compiles in Delphi 6. There are plans to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.