Solved

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

Posted on 1997-05-02
1
332 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

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

Suggested Solutions

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

860 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