Click here to Skip to main content
11,409,097 members (61,457 online)
Click here to Skip to main content

EnumSerialPorts v1.02 - Enumerating Serial Ports

, 3 Mar 2000
Rate this:
Please Sign up or sign in to vote.
A freeware MFC function to enumerate serial ports.
  • Download source files - 7 Kb
  • Introduction

    Welcome to EnumSerialPorts v1.01, a simple MFC function to enumerate the serial ports installed on your machine.

    API Reference
    Contacting the Author


    • Simple C style function interface.
    • The code works on both Windows 95/98 and NT.
    • The code is fully Unicode compliant and include Unicode built options in the workspace file.


    • To use the function in your code simply #include "enumser.cpp" in your project and #include "enumser.h" in which ever of your modules needs to make calls to the function.
    • Your code will need to include MFC either statically or dynamically.
    • To see the class in action, have a look at the main function in the module main.cpp.


    v1.0 (3 November 1998)
    • Initial Public release.

    v1.01 (23 February 1999)

    • Code now uses QueryDosDevice() if running on NT to determine which serial ports are available. This avoids having to open the ports at all. It should operate a lot faster in addition.

    V1.02 (12 December 1999)

    • Fixed a problem in the Win9x code path when trying to detect deactivated IRDA-ports. When trying to open those, you will get the error-code ERROR_GEN_FAILURE.

    API Reference


    void ::EnumerateSerialPorts(CUIntArray& ports);


    • ports -- Upon return this array will contain the port numbers of all the serial ports installed on the computer.

    Contacting the Author

    PJ Naughter
    12 December 1999


    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here


    About the Author

    PJ Naughter

    United States United States
    No Biography provided

    Comments and Discussions

    GeneralUintArray Pinmemberdrequinox4-Sep-06 11:44 
    GeneralProblem: Other devices starting with "Com"... PinmemberSupermagle11-Nov-05 4:03 
    GeneralRe: Problem: Other devices starting with "Com"... PinmemberSupermagle11-Nov-05 4:12 
    GeneralVIRTUAL SERIAL PORT PinmemberJoseph126-May-03 9:53 
    GeneralRe: VIRTUAL SERIAL PORT PinmemberJLT7623-Feb-05 17:28 

    Have you found any information on how to create a virtual comm port?

    Thank you,
    GeneralSuggestion for another method Pinmemberchris10919-Mar-02 4:03 
    GeneralThe way I do it ... Pinmemberanonymous24-Aug-01 8:36 
    GeneralIncorrect COM0 detection PinmemberAnonymous6-Aug-01 21:26 
    GeneralRe: Incorrect COM0 detection PinmemberAnonymous12-Aug-01 15:18 
    GeneralRe: Incorrect COM0 detection PinmemberAnonymous12-Aug-01 15:31 
    GeneralThere is a better way to enumerate ports... PinmemberChristian B25-Jul-01 2:15 
    GeneralHelp for Windows CE PinmemberChris Pichon19-May-01 6:48 
    GeneralRe: Help for Windows CE Pinmembersusilrani9-May-08 1:22 
    Generali need to detect a modem . . . Pinsussguy19-Sep-00 6:37 
    GeneralUse vector<UINT> instead of CUIntArray Pinsussleowlf9-Apr-00 17:22 
    GeneralRe: Use vector<UINT> instead of CUIntArray PinsussPJ Naughter16-May-00 14:57 
    GeneralRe: Use vector<UINT> instead of CUIntArray PinmemberAnonymous19-Apr-02 5:50 
    GeneralVirtual Ports PinsussCMG4-Apr-00 13:06 
    GeneralRe: Virtual Ports PinsussPJ Naughter5-Apr-00 12:46 
    GeneralRe: Virtual Ports PinsussEldad Kuperman13-Apr-00 0:25 
    GeneralRe: Virtual Ports PinsussEldad Kuperman13-Apr-00 0:27 
    GeneralRe: Virtual Ports PinsussPJ Naughter16-May-00 15:00 
    GeneralRe: Virtual Ports PinsussPJ Naughter17-May-00 4:13 
    GeneralRe: Virtual Ports PinmemberGin Hwee2-Sep-01 22:52 
    GeneralRe: Virtual Ports PinsussAnonymous12-Dec-03 0:38 
    GeneralRe: Virtual Ports Pinmemberpjnaughter12-Dec-03 1:36 
    GeneralRe: Virtual Ports PinmemberJoby10-Jun-05 3:06 
    GeneralRe: Virtual Ports Pinmemberpjnaughter12-Dec-03 5:20 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    | Advertise | Privacy | Terms of Use | Mobile
    Web01 | 2.8.150414.5 | Last Updated 4 Mar 2000
    Article Copyright 2000 by PJ Naughter
    Everything else Copyright © CodeProject, 1999-2015
    Layout: fixed | fluid