我怎樣才能找出默認的打印機是否或不使用vb.net或C#(在.NET 2.0)檢查默認打印機是與否
什麼是連接的打印機的端口號。
我正在使用PrinterSettings類,但沒有任何方法來獲取這些值。
我怎樣才能找出默認的打印機是否或不使用vb.net或C#(在.NET 2.0)檢查默認打印機是與否
什麼是連接的打印機的端口號。
我正在使用PrinterSettings類,但沒有任何方法來獲取這些值。
使用後:
string strDefaultPrinter;
using(var printServer = new LocalPrintServer())
{
strDefaultPrinter= printServer.DefaultPrintQueue.FullName);
}
通過這種方式,你可以在一個字符串中設置默認打印機,可與檢測打印機進行比較。
您可以使用此代碼獲取端口號。
private void cboPrinters_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
PrintQueue printer = cboPrinters.SelectedItem as PrintQueue;
string portname = printer.QueuePort.Name;
}
謝謝,但在.Net 2.0中不支持PrintQueue。 還有其他方法嗎? – Sudz 2013-05-09 05:31:47
檢查此鏈接是否有幫助。 http://www.codeproject.com/Articles/6069/How-to-Check-if-Your-Printer-is-Connected-using-C – 2013-05-09 05:38:23
嘿試試這個鏈接[鏈接](http://www.codeproject。 com/Articles/6069/How-to-Check-if-your-Printer-is-Connected-using-C) – 2013-05-09 05:41:41
但是,如何檢測默認打印機是打開還是關閉? – Sudz 2013-05-09 05:29:06
這裏是你的答案http://stackoverflow.com/questions/5001920/c-sharp-check-printer-status – Freelancer 2013-05-09 05:36:35
我使用的是.Net 2.0,你的解決方案可以與.Net 3.0或以上版本兼容。是否有其他方法? – Sudz 2013-05-09 05:42:36