General discussion

Locked

Priter status request

By mtadeu ·
My problem is that i can't display any message box in my software! The other problem is that i have to use the printer! When i send something to the printer, if there's an error...there it is...a message box reporting an error. I tryed to get the printer status( using GetPrinter/PRINTER_INFO_2->Status )with no success( always 0x00 ). I'm writing to the printer using WritePrinter spooler function.Maybe i could desable the error message boxes, but i still have to know the error...

Thanx for help
Miguel Tadeu

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Priter status request

by Peter Ritchie In reply to Priter status request

You're very limited to what you can do if you're just using OpenPrinter() and WritePrinter().

I haven't tested if this fulfills your problem of getting the correct status; but, you should probably use StartDoc before sending data to the printer.The JobID given by StartDoc can then be used with GetJob to get more information about the specific Job status (opposed to the printer status). If the job had a problem (more likely than the printer having a problem) then you should be able to get more coherent status.

If you're using C++, you should really consider using the MFC libraries for printing; it encapsulates most of this stuff so you don't have to deal with most of it.

Collapse -

Priter status request

by Shanghai Sam In reply to Priter status request

Sorry... I tryed to use MFC before the API....same result! The MFC implements the API directly( so it does the same thing that i do ). I'm also using StartDocPrinter/StartPagePrinter, so i should get to the same result! Thanx anyway

Collapse -

Priter status request

by maxwell edison In reply to Priter status request

The WritePrinter function notifies the print spooler that data should be written to the specified printer.

BOOL WritePrinter(
HANDLE hPrinter, // handle to printer object
LPVOID pBuf, // array of printer data
DWORD cbBuf, // size of array
LPDWORD pcWritten // bytes received
);
Parameters
hPrinter
[in] Handle to the printer. Use the OpenPrinter or AddPrinter function to retrieve a printer handle.
pBuf
[in] Pointer to an array of bytes that contains the data that should be written to the printer.
cbBuf
[in] Specifies the size, in bytes, of the array.
pcWritten
[out] Pointer to a value that receives the number of bytes of data that were written to the printer.
Return Values
If the function succeeds, the return value is a nonzero value.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Check this link:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/prntspol_7zqq.asp

for more info and further links.

Maxwell

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums