EnumSerialPorts v1.04
Welcome to EnumSerialPorts, A simple
MFC function to enumerate the serial ports installed on your machine.
Features
- Simple C style function interface.
- The code works on both Windows 95/98 and NT.
Internally the code calls GetDefaultCommConfig which does not require a call
to open the port.
- The code is fully Unicode compliant and
include Unicode built options in the workspace file.
Usage
- 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".
Copyright
- You are allowed to include the source code in
any product (commercial, shareware, freeware or otherwise) when your product
is released in binary form.
- You are allowed to modify the source code in
any way you want except you cannot modify the copyright details at the top
of each module.
- If you want to distribute source code with
your application, then you are only allowed to distribute versions released
by the author. This is to maintain a single distribution point for the
source code.
History
v1.0 (3 November 1998)
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.
v1.03 (17 May 2000)
- Code now uses GetDefaultCommConfig in all cases to detect the ports.
v1.04 (29 March 2001)
- Reverted code to use CreateFile or QueryDosDevice as it is much faster than using the GetDefaultCommConfig
method.
- Updated copyright message.
API
Reference
EnumerateSerialPorts
void ::EnumerateSerialPorts(CUIntArray& ports);
Parameters
ports Upon return this array will contain the port numbers
of all the serial ports installed on the computer
CONTACTING
THE AUTHOR
PJ Naughter
Email: pjna@naughter.com
Web: http://www.naughter.com
29 March 2001