How to send bytes to an parallel port (LPT1)

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.
mbrlaserAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mbrlaserAuthor Commented:
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
WhoPhlungPooCommented:
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
GalaaCommented:

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mbrlaserAuthor Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

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.