LocalPrintServer.GetDefaultPrintQueue Method ()

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Returns a reference to the default print queue of the LocalPrintServer.

Namespace:   System.Printing
Assembly:  System.Printing (in System.Printing.dll)

public static PrintQueue GetDefaultPrintQueue()

Return Value

Type: System.Printing.PrintQueue

The default PrintQueue.

Your application will have only UsePrinter access to the default queue, even if you have AdministrateServer rights to the print server. To open the queue with greater access, use one of the PrintQueue constructors that enables you to specify the desired access level.

The following example shows how to use this method to discover at run time the properties, and the types of those properties, of a print queue, without using reflection.


// Enumerate the properties, and their types, of a queue without using Reflection
LocalPrintServer localPrintServer = new LocalPrintServer();
PrintQueue defaultPrintQueue = LocalPrintServer.GetDefaultPrintQueue();

PrintPropertyDictionary printQueueProperties = defaultPrintQueue.PropertiesCollection;

Console.WriteLine("These are the properties, and their types, of {0}, a {1}", defaultPrintQueue.Name, defaultPrintQueue.GetType().ToString() +"\n");

foreach (DictionaryEntry entry in printQueueProperties)
{
    PrintProperty property = (PrintProperty)entry.Value;

    if (property.Value != null)
    {
        Console.WriteLine(property.Name + "\t(Type: {0})", property.Value.GetType().ToString());
    }
}
Console.WriteLine("\n\nPress Return to continue...");
Console.ReadLine();

.NET Framework
Available since 3.0
Return to top
Show: