?
Solved

How to send bytes to an parallel port (LPT1)

Posted on 2003-03-19
5
Medium Priority
?
473 Views
Last Modified: 2012-05-04
Dear Gentlemen:  
I need to send bytes to the parallel port of the computer (LPT1 or LPT2). The connected device to the port is not a printer. As I can make this from Delphi?

Thanks,


Mauro Badalacchi R.
0
Comment
Question by:mbrlaser
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 

Author Comment

by:mbrlaser
ID: 8169192
Thanks emadat, but the code 'Out Dx,Ax' return error 'Privileged Instruction'. Is it necessary to place some directive so that this operation is allowed?
0
 

Expert Comment

by:WhoPhlungPoo
ID: 8170062
Hello,

     In order to directly access any port under Windows, you need a device driver, there are several components that have what you need, here is one of them:

ZLPortIO

You can download it from www.torry.net
0
 

Accepted Solution

by:
Galaa earned 750 total points
ID: 8171298

1. FHandle := CreateFile('LPT1', GENERIC_READ or GENERIC_WRITE, FILE_SHARE_READ
or FILE_SHARE_WRITE, nil, OPEN_EXISTING, 0, 0);

2.NumberOfBytesToWrite := Length(Str);
EMStr := PChar(LocalAlloc(LMEM_FIXED, NumberOfBytesToWrite + 1));

CharToOem(PChar(Str), OEMStr);

 WriteFile(FHandle, OEMStr^, NumberOfBytesToWrite,
FNumberOfBytesWritten, nil)



0
 

Author Comment

by:mbrlaser
ID: 8171395
I already proved this option and it works well. It is necessary to include

closehandle(FHandle);

so that the data are sent to the port.

Thanks Galaa.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month14 days, 10 hours left to enroll

771 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