Click here to Skip to main content
13,046,679 members (66,725 online)
Rate this:
Please Sign up or sign in to vote.
Only found the serialport control in windows form application.

How about parallel port?

If i want to send a character 'a' towards a device by LPT port.

How can i achieve this?
Posted 15-Oct-10 5:57am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If you have installed a generic printer text driver and have that set to the LPT1 port (pretty standard) , then you can print to LPT1 as if it was a file.

System.IO.StreamWriter writer = new System.IO.StreamWriter(@\\.\LPT1);
writer.Write("Hello World");

You should read the Code Project article on parallel ports[^].

You can also find a lot of info on parallel ports here[^].

The above example code is in C#. For something in Visual Basic look at this article[^]
Read this Code Project article[^] on printing using Visual Basic.
newbievbnet 15-Oct-10 13:35pm
i try to translate it in vb however it giv me error
FileStream will not open Win32 devices such as disk partitions and tape drives. Avoid use of "\\.\" in the path.
CIDev 15-Oct-10 14:36pm
Try reading this article on programming parallel ports:
CIDev 15-Oct-10 14:43pm
I updated my answer with a link to an article on using the parallel port with VB.
newbievbnet 16-Oct-10 8:59am
erm i doubt is it working in c#?
i try in c# but same error.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 15 Oct 2010
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100