0

I'm working on a somehow a small application in Winforms where I can see the printers I have on my application with detailed information similar the the configuration site of the printers. Every block of code I find online is either giving me false when getting bool variables like this:

MachineName = "My Machine Name";
LocalPrintServer localPrintServer = new LocalPrintServer();
localPrintServer.Refresh();
PrintQueue pq = new PrintQueue(localPrintServer, MachineName.Trim());
pq.Refresh();
MessageBox.Show(pq.IsPrinting.ToString());

or I'm getting the "Win32 Access Denied" error like when using:

using (var ps = new PrintServer())
{
    using (var pq = new PrintQueue(ps, MachineName, PrintSystemDesiredAccess.UsePrinter))
    {
        foreach (var job in pq.GetPrintJobInfoCollection())
            MessageBox.Show("hi");
    }
}

I'm out of ideas, thank you in advance.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Is this answer any use? Seems very similar to what you have but it uses a `PrinterName` to find a specific print queue: https://stackoverflow.com/questions/5593448/how-do-i-retrieve-a-list-or-number-of-jobs-from-a-printer-queue – Matthew Watson Aug 25 '23 at 08:58
  • its the same but in another way, the "MachineName" in my code is a string variable containg the PrinterName – محمد السروجي Aug 25 '23 at 18:05

0 Answers0