CParallelPort v1.16 An MFC class to control
parallel ports on Windows (Obsolete)
The code is based on the ideas and code from the book "Parallel Port Complete"
which I would recommend you read, if you want to learn more about parallel ports
and their programmatic use. The class allows you to read and write values to the
port using low level port IO while at the same time making sure that the code does
not cause problems for other apps using the parallel ports using normal Win32 calls.
- Simple and clean C++ interface.
- All the code is UNICODE compliant and build configurations are provided
- The code works on NT, 2000, XP, 2003, Vista & 2008 just as well as on
95,98 & ME.
- The code can be used in a console application or GUI app without problems.
- The code implements a simple file transfer class which the sample app uses
to implement a simple client / server app to transfer files from PC to PC via "LPT1".
Testing on my lowly Pentium 233 laptop yielding a consistent transfer rate of
40 - 50 KB / S using Nibble mode on an SPP port.
- 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.
- To use the class in your code simply include parallelport.cpp in your project
and #include parallelport.h in which ever of your modules needs to make calls
to the classes.
- Your code will need to include MFC either statically or dynamically.
- You may want to add afxtempl.h to your pre compiled header to improve compilation
- To see the class in action, have a look at the code in _tmain in the module "main.cpp".
- If you are going to be using the CParallelPort code on Windows NT, Windows
2000, XP, 2003, Vista or 2008, then you will need to download and install the
freeware DriverLINX PortIO driver. As a convenience, you can download a self
extracting installer from the author's web site at
Alternatively you can download it from the DriverLINX download page.
The enclosed zip file contains the CParallelPort
source code, documentation and a simple MFC console app which implements a simple
client / server app to transfer files from PC to PC via "LPT1". For further
details on how to use the class have a look at function _tmain in the module main.cpp.
28 March 2014
- Please note that this code is now obsolete because the DriverLINK PortIO
driver is no longer available for x86 versions of Windows and more and more
installs of Windows are now x64 with no driver available for it at all. As an
application developer or hardware engineer you would be advised to look to more
modern interfaces such as USB which are very easy to integrate into your Windows
projects with the likes of
WinUSB, libusb and
V1.16 (30 December 2007)
- Updated the code and sample app to clean compile on VC 2008
- CParallelPortException::GetErrorMessage now uses Checked::tcsncpy_s if compiled
using VC 2005 or later.
V1.15 (24 December 2007)
- Updated copyright details
- CParallelPortException::GetErrorMessage now uses the FORMAT_MESSAGE_IGNORE_INSERTS
flag. For more information please see Raymond Chen's blog at
to Alexey Kuznetsov for reporting this issue.
- Updated the sample app to clean compile on VC 2005
V1.14 (9 July 2006)
- Updated copyright details.
- Renamed AfxThrowParallelException to ThrowParallelException and made it
a member of CParallelPort.
- CParallelPort is no longer derived from CObject as it was not really required
- Optimized CParallelPortSettings constructor code
- Optimized CParallelException constructor code
- Removed CParallelException destructor
- Optimized CParallelPort constructor code
- Renamed CParallelException class to CParallelPortException
- Removed CParallelPortFileTransfer destructor as it was not required.
- Code now uses newer C++ style casts instead of C style casts.
- Updated the documentation to use the same style as the web site
- Updated code to clean compile on VC 2005
V1.13 (24 September 2004)
- Fixed a problem in the sample app where there were two instances of the
CParallelPort which was causing problems with CArray upon startup.
- Fixed problems with the sample app when compiled for Unicode. The Linker
entry point symbol is now "wmainCRTStartup".
V1.12 (11 June 2003)
- Reviewed all places where exceptions are throw and the details which are
logged in TRACE statements.
V1.11 (12 April 2003)
- Updated copyright details.
- Updated documentation to refer to new DriverLinx web site.
- Code now issues compile time message if conio or afxpriv are not in your
V1.1 (21 July 2000)
- Now works on NT / Windows 2000 thanks to DriverLINX Port I/O Driver
- Made all typedefs and enums local to the appropiate class rather than polluting
the global namespace. You will get compiler errors if you have code using v1.0
of the class. It is a simple change to fix this, just to use the scope operator "CParallelPort::"
before all the enums you used.
V1.0 (5 April 2000)