Solved

write a byte to the parallel port under NT4.0?

Posted on 1997-05-02
1
329 Views
Last Modified: 2013-12-04
I tried to write a byte to the parallel port in this way:

      HANDLE hLPT;
      DWORD nNumberOfBytesWritten;
      BYTE  ccb;
      BOOL bWriteFile,bCloseHandle, bWait=FALSE, bOVResult;
      OVERLAPPED st_Overlapped;
      ccb=1;

      hLPT=CreateFile("LPT1",GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_FLAG_OVERLAPPED,NULL);
      bWriteFile=WriteFile(hLPT, &ccb, 1, &nNumberOfBytesWritten, &st_Overlapped);
      bCloseHandle=CloseHandle(hLPT);      

This works only if I have installed a printer driver to lpt1! Then, after proceeding, a print message window opens and tells me there is no paper in the printer, but I will not print!!!
I need a solution with about 10 or 20  rows, not a complicated VxD driver or something.
0
Comment
Question by:nil_dib
1 Comment
 
LVL 2

Accepted Solution

by:
gysbert1 earned 50 total points
ID: 1397072
I'm afraid you'll have to use a "complicated VxD" You're trying to access the printer port through the printer driver. It looks at the status lines on the port, and detects a paper out error. What you need is driver that allows arbitrary access to the port.

I know you're not using Delphi, but try this anyway:

Go to the Delphi superpage (sunsite.icm.edu.pl), click on search and type "port hardware" and click the 32 bit checkbox. The first result is a delphi component to allow arbitrary port access. It includes a VxD, which allows arbitrary port access. You should be able to use this VxD with your program as well...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now