C#没有获得打印机的任何状态。我打印并想知道打印机的状态,无论是“PRINTER IS PRINTING”还是“PRINTER OF OF PAPER”。
这是我的代码: -
string filePath = "C:\\Users\\fouzan\\Desktop\\abc.txt";
PrintDocument pd = new PrintDocument();
Process p = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = true;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.UseShellExecute = true;
startInfo.FileName = filePath;
startInfo.Verb = "print";
startInfo.Arguments = @"/p /h \" + filePath + "\"\"" + pd.PrinterSettings.PrinterName + "\"";
p.StartInfo = startInfo;
MessageBox.Show(p.StartInfo.ToString());
p.Start();
MessageBox.Show(p.Start().ToString());
LocalPrintServer server = new LocalPrintServer();
PrintQueue printQueue = server.GetPrintQueue("Samsung ML-2160 Series");
//this outputs "NONE":-
MessageBox.Show(printQueue.QueueStatus.ToString());
我收到“NONE”输出如何知道打印机是打印还是“缺纸”。
我从打印机属性中选择了默认打印机“Samsung ML-2160 Series”。