Assembly : System.Management;
public bool CheckPrinterStatus()
{
ManagementScope scope = new ManagementScope(@"\root\cimv2");
scope.Connect();
// Select Printers from WMI Object Collections
ManagementObjectSearcher PrinterCollection= new
ManagementObjectSearcher("SELECT * FROM Win32_Printer");
string printerName = "";
foreach (ManagementObject printer in PrinterCollection.Get())
{
printerName = printer["Name"].ToString().ToLower();
if (printerName.Equals(@"hp laserjet 1018"))
{
MessageBox.Show("Printer = " + printer["Name"]);
if (printer["WorkOffline"].ToString()=="True")
{
// Printer is offline
MessageBox.Show("Printer is not Connected.");
return false;
}
else
{
// Printer is Online
MessageBox.Show("Printer is Connected.");
return true;
}
}
}
}
Showing posts with label Check Printer Status in C#. Show all posts
Showing posts with label Check Printer Status in C#. Show all posts
Wednesday, October 20, 2010
Subscribe to:
Posts (Atom)
Mat Table Angular
Mat Table in Angular Mat table is used to display data . its a material designed styled data-table . For using Material Table MatTableMo...
-
CriteriaOperator criteria = new BinaryOperator("Age", 30, BinaryOperatorType.Greater); CriteriaOperator criteria = CriteriaOperato...
-
SortingCollection sc = new SortingCollection(); sc.Add (new SortProperty("field on which you want to sort",DevExpress.Xpo.DB.Sorti...
-
Minification and Uglyfication in Angular Deployement Minification : While building Angular Application white spaces , unused variable , u...