Currently, there is an app that outputs from the app to the printer.
Regarding disconnect detection,
I'm getting the printer status from the GetPrintQueue method in the LocalPrintServer class.
of the retrieved states
The IsOffline property is always false
When reseating the USB cable, the device and printer icons appear
The OS seems to be detecting that the printer has run out because it turns half gray when it is unplugged.
From the program, it will always be online (IsOffline=false) (I can detect the cover opening and missing paper...)
How else can I detect printer connectivity?
My current environment is Windows 7/.NetFramework 4.5, but I would like to know how to use it in Windows 8.1 and Windows 10.
At first, I thought that was the specification because it was for business use.
Is there any other standard way to detect it from the device and printer?
Trying to determine printer status always returns 0 for offline & online printers
Based on the answers above, it seems that the printer is offline or not can be determined by the Attributes value of the PRINTER_INFO_2 structure obtained by the GetPrinter function of the WIN32 API.
There was a code to get PRINTER_INFO_2 on the above page.
I think I can get PRINTER_INFO_2 and determine if the printer specified by the code below is online.
PRINTER_INFO_2printerInfo=GetPrinterInfo("SHARP MX-2610FN SPDL2-c");
if(printerInfo.Attributes&PRINTER_ATTRIBUTE_WORK_OFFLINE)>0)
{
label1.Text="Offline";
}
else
{
label1.Text="Online";
}
© 2024 OneMinuteCode. All rights reserved.