I've an application the needs to query the state of a printer before attempting to send it anything.if catch error out of paper or low paper and etc i can detect them.
but following code always return result to Ready when printer is no paper.
oManagementScope = new ManagementScope(ManagementPath.DefaultPath);
oManagementScope.Connect();
string sPrinterName = comboBox1.SelectedItem.ToString();
SelectQuery oSelectQuery = new SelectQuery();
oSelectQuery.QueryString = @"SELECT * FROM Win32_Printer WHERE Name = '" +
sPrinterName.Replace("\\", "\\\\") + "'";
ManagementObjectSearcher oObjectSearcher =new ManagementObjectSearcher(oManagementScope, oSelectQuery);
ManagementObjectCollection oObjectCollection = oObjectSearcher.Get();
foreach (ManagementObject MObj in oObjectCollection)
{
string myString = MObj["PrinterStatus"].ToString();
Int32 dStatus = Convert.ToInt32(myString);
label1.Text = printerStatus[dStatus];
}
thanks
Loading
Sam HobbsPosted Aug 10, 2011, 6:13 PM
Typically the status of a printer is only available to the device driver. Older printers do not even have a way to report status, except that there is a wire (physical metal wire) that could indicate out-of-paper.
So perhaps the priner device driver is not properly configure to allow Wiindows to know if the printer is ready, or perhaps the printer is not configured properly.