I need to write a program that finds all connected USB-printers of a Windows PC and send a file to a selected printer from this list. These two points are no problem and work pretty fine
First point
var printerQuery = new ManagementObjectSearcher("SELECT * from Win32_Printer");
i = 1;
foreach (var printer in printerQuery.Get())
{
var name = printer.GetPropertyValue("Name");
var status = printer.GetPropertyValue("Status");
var isDefault = printer.GetPropertyValue("Default");
var isNetworkPrinter = printer.GetPropertyValue("Network");
var PortName = printer.GetPropertyValue("PortName");
bool Connected = (bool)printer.GetPropertyValue("WorkOffline");
var Caption = printer.GetPropertyValue("Caption");
string s = "Name: " + name;
string nbr = "";
if (i.ToString().Length < 2) nbr = "0";
nbr += i.ToString();
listBoxUSBInfo.Items.Add(nbr + ": " + s);
listBoxUSBInfo.Items.Add(" Status: " + status);
listBoxUSBInfo.Items.Add(" Default: " + isDefault);
listBoxUSBInfo.Items.Add(" Network: " + isNetworkPrinter);
listBoxUSBInfo.Items.Add(" PortName: " + PortName);
if ( Connected) listBoxUSBInfo.Items.Add(" Connected: True");
if (!Connected) listBoxUSBInfo.Items.Add(" Connected: False");
listBoxUSBInfo.Items.Add(" Caption: " + Caption);
i++;
}
Second point
Is quite easy:
The class "RawPrinterHelper" is well known in this forum, I think
RawPrinterHelper.SendFileToPrinter("PrinterName", "FileName");
But now my problem.
I must print very large files (more than 100.000 pages) and the operator wants to see, how many pages are currently printed. Is it possible to get this information? For example every 3 seconds, so that I can display at on the screen.
Aucun commentaire:
Enregistrer un commentaire