|
-
Aug 20th, 2010, 03:39 AM
#1
Thread Starter
Lively Member
how to check printer status!!plz help
this is my code code and its not working...
the value of (bool)printer.Properties["WorkOffline"].Value is always false even if the printer is online; how to fix this
Code:
public bool CheckMyPrinter(string printerToCheck)
{
string printerName = " ";
// string stat = " ";
// ManagementScope scope = new ManagementScope(@"\root\cimv2");
// scope.Connect();
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Printer");
bool IsReady = false;
foreach (ManagementObject printer in searcher.Get())
{
printerName = printer["Name"].ToString();
if (printerName.Equals(printerToCheck))
{
//stat = printer["WorkOffline"].ToString().ToLower();
if ((bool)printer.Properties["WorkOffline"].Value == false)
{
IsReady = true;
}
}
}
return IsReady ;
}
-
Aug 20th, 2010, 03:55 AM
#2
Re: how to check printer status!!plz help
Thread moved from the ' UtilityBank - Tutorials' forum (which is for you to post tutorials you have written, not questions) to the 'C#' forum
-
Aug 20th, 2010, 08:48 AM
#3
Re: how to check printer status!!plz help
The property is probably not what you think it is.
When WorkOffline is enabled, printer communication is set to a halt.
It is not used to check the printer status, but rather a function to stop the communication.
If that is what you thought it was, you need to review the logic here (it's actually working fine).
WorkOffline = false, which means that the spooler is NOT working offline, so it's working online.
Delete it. They just clutter threads anyway.
-
Aug 22nd, 2010, 07:45 PM
#4
Thread Starter
Lively Member
Re: how to check printer status!!plz help
i did not get what you mean can you elaborate please
-
Aug 22nd, 2010, 08:53 PM
#5
Re: how to check printer status!!plz help
This is what MSDN has for us:
 Originally Posted by MSDN
WorkOffline
Data type: boolean
Access type: Read/write
If TRUE, you can queue print jobs on the computer when the printer is offline.
Windows 2000 and Windows NT 4.0: This property is not supported.
You probably need property like PrinterStatus
Or take a look at MSDN entry on Win32_Printer Class.
Hope it helps.
-
Aug 23rd, 2010, 09:28 PM
#6
Thread Starter
Lively Member
Re: how to check printer status!!plz help
can you give me a sample process please
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|