Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: .NET3.0 C++/CLI C# VB.NET
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 6: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 at 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 at 15-Oct-10 14:36pm
Try reading this article on programming parallel ports:
CIDev at 15-Oct-10 14:43pm
I updated my answer with a link to an article on using the parallel port with VB.
newbievbnet at 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
0 Sergey Alexandrovich Kryukov 449
1 Maciej Los 430
2 OriginalGriff 320
3 CHill60 240
4 CPallini 210
0 Sergey Alexandrovich Kryukov 10,102
1 OriginalGriff 9,495
2 Peter Leow 5,241
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 3,076

Advertise | Privacy | Mobile
Web01 | 2.8.150327.1 | Last Updated 15 Oct 2010
Copyright © CodeProject, 1999-2015
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