Export (0) Print
Expand All

LocalPrintServer Class

Represents the local print server (the computer on which your application is running) and enables management of its print queues.

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

public sealed class LocalPrintServer : PrintServer

The LocalPrintServer type exposes the following members.

  NameDescription
Public methodLocalPrintServer()Initializes a new instance of the LocalPrintServer class.
Public methodLocalPrintServer(LocalPrintServerIndexedProperty[])Initializes a new instance of the LocalPrintServer class that has the specified LocalPrintServerIndexedProperty array.
Public methodLocalPrintServer(PrintSystemDesiredAccess)Initializes a new instance of the LocalPrintServer class that has the specified PrintSystemDesiredAccess.
Public methodLocalPrintServer(String[])Initializes a new instance of the LocalPrintServer class that has the specified properties.
Public methodLocalPrintServer(LocalPrintServerIndexedProperty[], PrintSystemDesiredAccess)Initializes a new instance of the LocalPrintServer class that has the specified LocalPrintServerIndexedProperty array and the specified PrintSystemDesiredAccess.
Public methodLocalPrintServer(String[], PrintSystemDesiredAccess)Initializes a new instance of the LocalPrintServer class that has the specified properties and PrintSystemDesiredAccess.
Top

  NameDescription
Public propertyBeepEnabledGets or sets a value that indicates whether the print server beeps in response to an error condition in the printer. (Inherited from PrintServer.)
Public propertyDefaultPortThreadPriorityInfrastructure. Do not use. (Inherited from PrintServer.)
Public propertyDefaultPrintQueueGets or sets the default print queue.
Public propertyDefaultSchedulerPriorityInfrastructure. Do not use. (Inherited from PrintServer.)
Public propertyDefaultSpoolDirectoryGets or sets the path where the print server's spool files are located. (Inherited from PrintServer.)
Public propertyEventLogGets or sets the type of events that the print server logs. (Inherited from PrintServer.)
Public propertyMajorVersionGets the major version of the operating system. (Inherited from PrintServer.)
Public propertyMinorVersionGets the minor version within the major version of the operating system. (Inherited from PrintServer.)
Public propertyNameGets the name of the print server. (Inherited from PrintServer.)
Public propertyNetPopupGets or sets a value that indicates whether notifications that a print job has finished are sent to either the print server or the client computer. (Inherited from PrintServer.)
Public propertyParentGets the parent of the object. (Inherited from PrintSystemObject.)
Public propertyPortThreadPriorityGets or sets the thread priority for the process that manages I/O through the printer ports. (Inherited from PrintServer.)
Public propertyPropertiesCollectionGets a collection of attribute and value pairs. (Inherited from PrintSystemObject.)
Public propertyRestartJobOnPoolEnabledGets or sets a value that indicates whether users can restart jobs after an error occurs if printer pooling is enabled. (Inherited from PrintServer.)
Public propertyRestartJobOnPoolTimeoutGets or sets a value that indicates the wait time before a job can be restarted, if an error occurs when printer pooling is also enabled. (Inherited from PrintServer.)
Public propertySchedulerPriorityGets or sets the thread priority for the process that routes print jobs from applications to print queues. (Inherited from PrintServer.)
Public propertySubSystemVersionGets the version of the print spooler system. (Inherited from PrintServer.)
Top

  NameDescription
Public methodCommitWrites any changes that your application made to the properties of the LocalPrintServer to the actual print server that the object represents. (Overrides PrintServer.Commit().)
Public methodConnectToPrintQueue(PrintQueue)Connects the local print server to the specified PrintQueue.
Public methodConnectToPrintQueue(String)Connects to the print queue that is specified by using the String.
Public methodDisconnectFromPrintQueue(PrintQueue)Disconnects the local print server from the specified PrintQueue.
Public methodDisconnectFromPrintQueue(String)Disconnects from the print queue that is specified in the String.
Public methodDispose()Releases all resources used by the PrintSystemObject. (Inherited from PrintSystemObject.)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodStatic memberGetDefaultPrintQueueReturns a reference to the default print queue of the LocalPrintServer.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetPrintQueue(String)Obtains a reference to the named print queue from the print server. (Inherited from PrintServer.)
Public methodGetPrintQueue(String, String[])Gets a specified print queue from the print server. (Inherited from PrintServer.)
Public methodGetPrintQueues()Gets the collection of print queues that the print server hosts. (Inherited from PrintServer.)
Public methodGetPrintQueues(EnumeratedPrintQueueTypes[])Gets the collection of print queues of the specified types that are named in EnumeratedPrintQueueTypes and hosted by the print server. (Inherited from PrintServer.)
Public methodGetPrintQueues(PrintQueueIndexedProperty[])Gets a collection of print queues that are hosted by the print server and initialized only in the properties that are specified in the PrintQueueIndexedProperty array. (Inherited from PrintServer.)
Public methodGetPrintQueues(String[])Gets a collection of print queues that are hosted by the print server and that are initialized only in the specified properties. (Inherited from PrintServer.)
Public methodGetPrintQueues(PrintQueueIndexedProperty[], EnumeratedPrintQueueTypes[])Gets a collection of print queues of the specified types. These print queues are only initialized in the properties that are specified in the PrintQueueIndexedProperty array. (Inherited from PrintServer.)
Public methodGetPrintQueues(String[], EnumeratedPrintQueueTypes[])Gets the collection of print queues, which are of the specified EnumeratedPrintQueueTypes and are initialized only in the specified properties. (Inherited from PrintServer.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInstallPrintQueue(String, String, String[], String, PrintPropertyDictionary)Installs a print queue, and associated printer driver, on the print server. (Inherited from PrintServer.)
Public methodInstallPrintQueue(String, String, String[], String, PrintQueueAttributes)Installs a print queue, and associated printer driver, on the print server. (Inherited from PrintServer.)
Public methodInstallPrintQueue(String, String, String[], String, PrintQueueAttributes, PrintQueueStringProperty, Int32, Int32)Installs a prioritized print queue, and associated printer driver, on the print server. (Inherited from PrintServer.)
Public methodInstallPrintQueue(String, String, String[], String, PrintQueueAttributes, String, String, String, String, Int32, Int32)Installs a shared, prioritized print queue, and associated printer driver, on the print server. (Inherited from PrintServer.)
Public methodRefreshUpdates the properties of the LocalPrintServer object so that their values match the values of the print server that the object represents. (Overrides PrintServer.Refresh().)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

When your application writes a value to a property of the LocalPrintServer object, that change has no effect until the value is passed to the computer that is represented by the LocalPrintServer object. To ensure that the change in value takes effect, use the Commit method.

In addition, other applications may also change the print service properties of the computer. To ensure that the LocalPrintServer object used by your application has the latest actual values, use the Refresh method.

Caution noteCaution

Classes within the System.Printing namespace are not supported for use within a Windows service or ASP.NET application or service. Attempting to use these classes from within one of these application types may produce unexpected problems, such as diminished service performance and run-time exceptions.

If you want to print from a Windows Forms application, see the System.Drawing.Printing namespace.

The following example shows how to create an instance of the LocalPrintServer class.

// -------------------- GetPrintXpsDocumentWriter() ------------------- 
/// <summary> 
///   Returns an XpsDocumentWriter for the default print queue.</summary> 
/// <returns> 
///   An XpsDocumentWriter for the default print queue.</returns> 
private XpsDocumentWriter GetPrintXpsDocumentWriter()
{
    // Create a local print server
    LocalPrintServer ps = new LocalPrintServer();

    // Get the default print queue
    PrintQueue pq = ps.DefaultPrintQueue;

    // Get an XpsDocumentWriter for the default print queue
    XpsDocumentWriter xpsdw = PrintQueue.CreateXpsDocumentWriter(pq);
    return xpsdw;
}// end:GetPrintXpsDocumentWriter()

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft