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
Hi,
You can use the following API to retrieve information
about a specified printer:
GetPrinter()
http://msdn.microsoft.com/en-us/library/ms535494(VS.85).aspx
Kellie.
You can not use ReadPrinter to read data from a Windows printer object.
Actually what you want is read from the "port" not the "printer". But that
also is not permitted (unless you are a "language monitor"). You can use the
"Bidi communication interface" (if the current language monitor supports
this)
Your best choice when using USB, is to open the USB port directly
--
Christoph Lindemann
Undocumented Printing
http://www.undocprint.org/
"Carlo McKee" <Log...@newsgroup.nospam> wrote in message
news:%23LWpHjt...@TK2MSFTNGP05.phx.gbl...