Skip to content

Can I show this in c#

Asp.Net Hein

Asp.Net Hein

Asked Apr 29, 2015, 6:54 PM EDT3 answers
Share
LinkedInX
Can I show this dialog box << See what's printing>> in c#?
 
Normally is when you choose the printer and right click on the printer and then choose "See what's printing.".Now I want to show this dialog in my c# program.
If you can help me, please help.
Thanks a lot .

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Manoj Bhoir
    0
    Hi,

    You can use the .NET 3.0 PrintQueue class in the System.Printing namespace. Its NumberOfJobs property tells you how many jobs are queued, GetPrintJobInfoCollection() returns details on all the jobs. Beware that it doesn't have any events that tells you that the job collection changed, you need to poll with a timer.

    private int GetNumberOfPrintJobs()
    {
        LocalPrintServer server = new LocalPrintServer();
        PrintQueueCollection queueCollection = server.GetPrintQueues();
        PrintQueue printQueue = null;

        foreach (PrintQueue pq in queueCollection)
        {
            if (pq.FullName == PrinterName)
                printQueue = pq;
        }

        int numberOfJobs = 0;
        if (printQueue != null)
            numberOfJobs = printQueue.NumberOfJobs;

        return numberOfJobs;
    }

    Or

    public static void WritePrinterJobs()
        {
            while (true)
            {
                foreach (var job in              LocalPrintServer.GetDefaultPrintQueue().GetPrintJobInfoCollection())
                {
                    Console.WriteLine(job.Submitter + " " + job.TimeJobSubmitted.ToShortDateString());
                }
                Thread.Sleep(100);
            }
        }
    0
  • Asp.Net Hein
    0
    Thanks a lot.

    But how I get the printer name??Can you help me again?
    0
  • Asp.Net Hein
    0
    I already try ,  but it does not work .
    Another solution for me?
    0