c# check printer status

前端 未结 4 531
北海茫月
北海茫月 2020-12-25 15:31

in my application (Windows 7, VS2010) i have to decrement a credit counter after successfully printing an image. Anyway, before starting the entire process, i\'d like to kno

4条回答
  •  再見小時候
    2020-12-25 15:58

    You can do this with printer queues as @mark_h pointed out above.

    However, if your printer is not the default printer you need to load that printer's queue instead. What you need to do instead of calling server.DefaultPrintQueue you would need to load the correct queue by calling GetPrintQueue() then pass it the printer name and an empty string array.

    //Get local print server
    var server = new LocalPrintServer();
    
    //Load queue for correct printer
    PrintQueue queue = server.GetPrintQueue(PrinterName, new string[0] { }); 
    
    //Check some properties of printQueue    
    bool isInError = queue.IsInError;
    bool isOutOfPaper = queue.IsOutOfPaper;
    bool isOffline = queue.IsOffline;
    bool isBusy = queue.IsBusy;
    

提交回复
热议问题