ReadPrint Failure. How to use it properly



I am trying to retrieve data from a bidirectional printer using the
ReadPrint API function.
The printer I am using is connected via USB.
Issue:

The ReadPrint function is returning false. The error code retrieved by
GetLastError is 6 (ERR_INVALID_HANDLE).

Before I use ReadPrint I create a printer handle using the OpenPrint API
function which returns true. Immediately after the OpenPrinter returns I
check if my handle is not invalid and is not. Below is a snippet of my
calls.


//The open printer does return true.
if(!OpenPrinter(( (LPTSTR)(pPrinterName)), &hPrinter, NULL ) )
{
DisplayError(GetLastError(),"GetPrinterStatus: OpenPrinter");
return (FALSE);
}

//I check if I have a Valid Handle and I do
if (hPrinter == INVALID_HANDLE_VALUE)
{
DisplayError(GetLastError(), "GetPrinterStatus: hPrinter invalid");
return (FALSE);
}

//Now that Open the printer and I have a handle I use ReadPrint
//This function actually returns false. The GetLastError is 6
(ERR_INVALID_HANDLE)
//But why is invalid handle if the OpenPrinter gave me a valid handle
if (!ReadPrinter(hPrinter, &Status, 16, &bytesRead))
{
DisplayError( GetLastError(), "GetPrinterStatus: ReadPrinter) );
return (FALSE);
}

I am positive I am getting a good handle from the OpenPrinter since I can
use OpenPrinter to write to the printer using the WritePrinter API. I can
successfully print using WritePrinter but fail to ReadPrinter.

Please advice what I may doing wrong or is there any other API to get data
from a printer.

Thank you


.



Relevant Pages

  • Re: Retrieving Data from printer using ReadPrinter API
    ... The ReadPrint function is returning false. ... GetLastError is 6. ... Before I use ReadPrint I create a printer handle using the OpenPrint API ... Immediately after the OpenPrinter returns I ...
    (microsoft.public.win32.programmer.kernel)
  • Re: ReadPrint Failure. How to use it properly
    ... The ReadPrint function is returning false. ... GetLastError is 6. ... Before I use ReadPrint I create a printer handle using the OpenPrint API ... Immediately after the OpenPrinter returns I ...
    (microsoft.public.win32.programmer.gdi)
  • Retrieving Data from printer using ReadPrinter API
    ... I am trying to retrieve data from a bidirectional printer using the ... The ReadPrint function is returning false. ... Before I use ReadPrint I create a printer handle using the OpenPrint API ... Immediately after the OpenPrinter returns I ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Retrieving Data from printer using ReadPrinter API
    ... "Bidi communication interface" (if the current language monitor supports ... The ReadPrint function is returning false. ... Before I use ReadPrint I create a printer handle using the OpenPrint API ... Immediately after the OpenPrinter returns I ...
    (microsoft.public.win32.programmer.kernel)

Loading