Share via


LocalPrintServer.GetDefaultPrintQueue Método

Definición

Devuelve una referencia a la cola de impresión predeterminada de LocalPrintServer.

public:
 static System::Printing::PrintQueue ^ GetDefaultPrintQueue();
public static System.Printing.PrintQueue GetDefaultPrintQueue ();
static member GetDefaultPrintQueue : unit -> System.Printing.PrintQueue
Public Shared Function GetDefaultPrintQueue () As PrintQueue

Devoluciones

La clase PrintQueue predeterminada.

Ejemplos

En el ejemplo siguiente se muestra cómo usar este método para detectar en tiempo de ejecución las propiedades y los tipos de esas propiedades, de una cola de impresión, sin usar la reflexión.


// 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();

' Enumerate the properties, and their types, of a queue without using Reflection
Dim localPrintServer As New LocalPrintServer()
Dim defaultPrintQueue As PrintQueue = LocalPrintServer.GetDefaultPrintQueue()

Dim printQueueProperties As PrintPropertyDictionary = defaultPrintQueue.PropertiesCollection

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

For Each entry As DictionaryEntry In printQueueProperties
    Dim [property] As PrintProperty = CType(entry.Value, PrintProperty)

    If [property].Value IsNot Nothing Then
        Console.WriteLine([property].Name & vbTab & "(Type: {0})", [property].Value.GetType().ToString())
    End If
Next entry
Console.WriteLine(vbLf & vbLf & "Press Return to continue...")
Console.ReadLine()

Comentarios

La aplicación solo UsePrinter tendrá acceso a la cola predeterminada, incluso si tiene AdministrateServer derechos para el servidor de impresión. Para abrir la cola con mayor acceso, use uno de los PrintQueue constructores que le permite especificar el nivel de acceso deseado.

Se aplica a