Lexikos
Joined: 17 Oct 2006 Posts: 2699 Location: Australia, Qld
|
Posted: Fri Nov 16, 2007 1:50 am Post subject: |
|
|
| Quote: | | Is there a way to know if a printer is out of paper? | Possibly, but not via printui.dll.
I thought I'd point out that the text in BoBo's original post can be reproduced (in your current language) by typing this at a command prompt:
| Code: | | rundll32 printui.dll,PrintUIEntry /? |
Edit: Here's my first attempt at reporting printer status:
| Code: | DllCall("LoadLibrary","str","winspool.drv")
if ! DllCall("winspool.drv\OpenPrinterA","str","HP PSC 750xi","uint*",hPrinter,"uint",0)
{
MsgBox OpenPrinter failed.`nErrorLevel: %ErrorLevel%`nLastError: %A_LastError%
return
}
DllCall("winspool.drv\GetPrinterA","uint",hPrinter,"uint",2,"uint",0,"uint",0,"uint*",req)
if (A_LastError = 122)
{ ; ERROR_INSUFFICIENT_BUFFER
VarSetCapacity(pi,req)
if DllCall("winspool.drv\GetPrinterA","uint",hPrinter,"uint",2,"uint",&pi,"uint",req,"uint*",req)
Status := NumGet(pi,72)
}
if Status =
MsgBox GetPrinter failed.`nErrorLevel: %ErrorLevel%`nLastError: %A_LastError%
DllCall("winspool.drv\ClosePrinter","uint",hPrinter)
MsgBox % Status
/*
PRINTER_STATUS_PAUSED = 0x00000001
PRINTER_STATUS_ERROR = 0x00000002
PRINTER_STATUS_PENDING_DELETION = 0x00000004
PRINTER_STATUS_PAPER_JAM = 0x00000008
PRINTER_STATUS_PAPER_OUT = 0x00000010
PRINTER_STATUS_MANUAL_FEED = 0x00000020
PRINTER_STATUS_PAPER_PROBLEM = 0x00000040
PRINTER_STATUS_OFFLINE = 0x00000080
PRINTER_STATUS_IO_ACTIVE = 0x00000100
PRINTER_STATUS_BUSY = 0x00000200
PRINTER_STATUS_PRINTING = 0x00000400
PRINTER_STATUS_OUTPUT_BIN_FULL = 0x00000800
PRINTER_STATUS_NOT_AVAILABLE = 0x00001000
PRINTER_STATUS_WAITING = 0x00002000
PRINTER_STATUS_PROCESSING = 0x00004000
PRINTER_STATUS_INITIALIZING = 0x00008000
PRINTER_STATUS_WARMING_UP = 0x00010000
PRINTER_STATUS_TONER_LOW = 0x00020000
PRINTER_STATUS_NO_TONER = 0x00040000
PRINTER_STATUS_PAGE_PUNT = 0x00080000
PRINTER_STATUS_USER_INTERVENTION = 0x00100000
PRINTER_STATUS_OUT_OF_MEMORY = 0x00200000
PRINTER_STATUS_DOOR_OPEN = 0x00400000
PRINTER_STATUS_SERVER_UNKNOWN = 0x00800000
PRINTER_STATUS_POWER_SAVE = 0x01000000
PRINTER_STATUS_SERVER_OFFLINE = 0x02000000
PRINTER_STATUS_DRIVER_UPDATE_NEEDED = 0x04000000 | It works... but requires the printer name to be specified, and seems to only report PRINTER_STATUS_ERROR.
| Microsoft wrote: | | Note, however, that the default port monitor for Windows does not usually set more than the PRINTER_STATUS_ERROR bit of a Printer's Status member. | Specifying "uint",0 for the printer name (in OpenPrinter) gets the local print server, but calling GetPrinter on the returned handle seems to always result in ERROR_INVALID_LEVEL.
You might like to try getting the status of the current print job, as described in How to get the status of a printer and a print job. |
|