Click here to Skip to main content
Rate this: bad
good
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
tuolesi797

1 solution

Rate this: bad
good
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”);
writer.Flush();
writer.Close();
 

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

You can also find a lot of info on parallel ports here[^].
 
[added]
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.
  Permalink  
v3
Comments
newbievbnet at 15-Oct-10 13:35pm
   
erm
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: http://www.aaroncake.net/electronics/vblpt.htm
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 OriginalGriff 390
1 Sergey Alexandrovich Kryukov 329
2 BillWoodruff 210
3 Afzaal Ahmad Zeeshan 204
4 CPallini 185
0 OriginalGriff 5,560
1 DamithSL 4,476
2 Maciej Los 3,942
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,175


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