LocalPrintServer.GetDefaultPrintQueue Metodo

Definizione

Restituisce un riferimento alla coda di stampa predefinita dell'oggetto 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

Restituisce

Oggetto PrintQueue predefinito.

Esempio

Nell'esempio seguente viene illustrato come usare questo metodo per individuare in fase di esecuzione le proprietà e i tipi di tali proprietà, di una coda di stampa, senza usare la 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();

' 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()

Commenti

L'applicazione avrà accesso solo UsePrinter alla coda predefinita, anche se si dispone AdministrateServer dei diritti per il server di stampa. Per aprire la coda con maggiore accesso, usare uno dei costruttori che consente di specificare il livello di PrintQueue accesso desiderato.

Si applica a