Interfacing the LPT-port using C++ under WinNT

Posted on 2003-03-21
Medium Priority
Last Modified: 2008-01-16
I have made a digital circuit which I want to test using the parallel port (instead of a microcontroller). I thought this was very simple, bus I discovered "_outp" does not work under WinNT. Then I found some alternatives:
- use a VxD (???)
- use a device driver (where do I get such a driver and how to use it?)
- use CreateFile("LPT1", .....) en WriteFile() (how?)
What is the best way to send some bits to the 8 datapins on the LPT-port in Visual C++ (Win32 Console App)?
I am just a beginner in C-programming, so keep it easy ;-)

Hope you can help me.
Question by:Svens

Expert Comment

ID: 8180508
I think CreateFile is the best, because it works from Win95 till WinXP and you don't need extra drivers (which is always a problem if you give the programm out of your hands).
Also with Createfile you can just use another device (eg. serial port or even TCP) with very little codechanges but i guess that's irrelevant for you :).


Expert Comment

ID: 8180595
It is not possible in NT (and XP,2000) to access hardware directly on the user level. You can write a device driver to access the hardware, but for the parallel port others did allready do the job.

Have a look at http://www.lvr.com/parport.htm

You will also find a link to freeware drivers to access the parallel port directly ...


Accepted Solution

ivec earned 600 total points
ID: 8181375
You need a 3rd-party driver on WinNT.
For parallel port access, the free DriverLINX port I/O driver is very easy to install and use.
You can find it at:

  http://www.driverlinx.com/DownLoad/dnload.htm#Windows 95/NT Port I/O Driver

I used it for several projects, under NT/Win2000/XP/etc, without encountering any problem.

You just need to use a provided function call instead of directly reading/writing to an address.

Expert Comment

ID: 8183018
Yes, that's what I forgot to say: Using the driver is easier than struggling with the functions yourself.
Probably the driver is only a wrapper that translates an easy to use interface to the windows functions. Alone the fact that such drivers exist proofs, that it's not so much fun doing it yourself. Nevertheless you learn a lot and have the highest level of control, if you use CreateFile ;-).
If you don't need full control (asynchronous acess, change standard timings/timeouts our some other crazy stuff) using a driver is the quickest way to implement something.

That's really a nice link! :)


Author Comment

ID: 8244596
This is really the link I needed: It was very simple to me to install and use the software.


Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question