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 ; }


Reply With Quote
