c# check printer status

前端 未结 4 529
北海茫月
北海茫月 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:43

    The PrintQueue class in the System.Printing namespace is what you are after. It has many properties that give useful information about the status of the printer that it represents. Here are some examples;

            var server = new LocalPrintServer();
    
            PrintQueue queue = server.DefaultPrintQueue;
    
            //various properties of printQueue
            var isOffLine = queue.IsOffline;
            var isPaperJam = queue.IsPaperJammed;
            var requiresUser = queue.NeedUserIntervention;
            var hasPaperProblem = queue.HasPaperProblem;
            var isBusy = queue.IsBusy;
    

    This is by no means a comprehensive list and remember that it is possible for the queue to have one or more of these statuses so you'll have to think about the order in which you handle them.

提交回复
热议问题