Ext: http://blog.csdn.net/lijipan/archive/2005/04/18/352678.aspx
To obtain the status of a printer, you should define a union.
Enum Printerstatus
{
Other states = 1,
Unknown
Free
is printing,
Preheating
Stop printing,
In print,
Offline
}
"Printing" and "printing" are the same meaning, as to why it is so, not yet known.
Add a system.management reference to the program: using System.Management;
Then write the function to get the printer status as follows:
<summary>
Get the current state of the printer
</summary>
<param name= "Printerdevice" > Printer device name </param>
<returns> Printer Status </returns>
Private Printerstatus Getprinterstat (string printerdevice)
{
Printerstatus ret=0;
String path=@ "Win32_Printer. Deviceid= ' "+printerdevice+" ";
ManagementObject printer=new ManagementObject (path);
Printer. Get ();
ret= (Printerstatus) Convert.ToInt32 (printer. properties["Printerstatus"]. Value);
return ret;
}
Call Example:
MessageBox.Show (Getprinterstat ("////192.168.0.88//samsung scx-4x16 Series"). ToString ());
trackback:http://tb.blog.csdn.net/trackback.aspx?postid=352678
Added: System.Windows.Forms.MessageBox.Show (printer. properties["WorkOffline"]. Value.tostring ());
You can obtain whether the printer is offline.