Search code examples
c#wpfprintingprintqueue

Comparing PrintQueue to determine default print queue


I am retrieving the default print queues thanks to the help of this question. I am also able to determine the DefaultPrintQueue

But how does one properly determine what print queue in the list of print queues is equal to the DefaultPrintQueue?

I've tried:

var dq = LocalPrintServer.GetDefaultPrintQueue();
foreach(PrintQueue pq in pqcOnLocalServer)
{
    if(pq.Equals(dq))
    {
        System.Console.WriteLine("Found default"); 
    }
}

but the two objects obviously won't be the same. I would then assume I could compare properties of each PrintQueue with the default, but what properties should be used to determine, 100%, that the two PrintQueues are referring to the same PrintQueue?


Solution

  • This question might have done well on Expert Exchange, or Server Exchange. What I've found is that a print server will not allows printers on the server which have existing names already on the printer server. With that being said, a printer must have a unique name per server.

    With that being said, a user must be careful to not only compare printer names to ensure that they are unique, but they must also compare the printer server that they are on. For example, when enumerating connected a printers. A computer could be connected to two print servers where there is a \\PRNTSRVR1\HQ_LaserJet01 and \\PRNTSRVR2\HQ_LaserJet01; so checking the connected server is important too.