ReadPrinter() returns invalid handle error

  • Thread starter Thread starter Sergey
  • Start date Start date
S

Sergey

Hi, everybody,

My question is a FAQ probably here, but I could not find nothing helpful
using search.

I try to read data back from my LPT connected printer. I follow standard
sequence of calls:
OpenPrinter, StartDocPrinter, StartPagePrinter, WritePrinter, ReadPrinter,
EndPagePrinter, EndDocPrinter, ClosePrinter.
The WritePrinter() call succeeds and the data arrive the printer
successfully. But the next ReadPrinter() call fails with GetLastError() == 6
saying "The handle is invalid".
My printer supports bidirectional communication. LPT port suppports it too.
The printer also supports PJL correctly. The printer driver supports Bi-di
as well, at least a checkbox "Enable bidirectional support" on Ports tab of
printer properties is enabled and marked.
The printer driver has own language monitor (actually I have tried also with
PJL Language Monitor with the same result).
It seems, that the problem is in the pritner driver, which does not support
bidirectional communication properly.

Should my sequence succeed with PJL Language Monitor (pjlmon.dll)?
Could you tell me, what are the requirements for the printer driver and/or
language montor in order to support ReadPrinter() call?

The language monitors, that I have tried, export old-fashioned
InitializePrintMonitor() function instead of recommended
InitializePrintMonitor2(). Could this be a reason?
InitializePrintMonitor() of my language monitors supports (at least declares
in MONITOREX structure) all needed functions including ReadPort() and
GetPrinterDataFromPort(), so I assume they must support bidirectional mode.

What are the conditions under which ReadPrinter() works?

Thank you.

Sergey.

PS: I use Windows 2000 Professional SP4.
 
Back
Top