LocalPrintServer 类

定义

表示本地打印服务器(应用程序正在其上运行的计算机)和启用其打印队列的管理。Represents the local print server (the computer on which your application is running) and enables management of its print queues.

public ref class LocalPrintServer sealed : System::Printing::PrintServer
public sealed class LocalPrintServer : System.Printing.PrintServer
type LocalPrintServer = class
    inherit PrintServer
Public NotInheritable Class LocalPrintServer
Inherits PrintServer
继承

示例

下面的示例演示如何创建 LocalPrintServer 类的实例。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()
' -------------------- GetPrintXpsDocumentWriter() -------------------
''' <summary>
'''   Returns an XpsDocumentWriter for the default print queue.</summary>
''' <returns>
'''   An XpsDocumentWriter for the default print queue.</returns>
Private Function GetPrintXpsDocumentWriter() As XpsDocumentWriter
    ' Create a local print server
    Dim ps As New LocalPrintServer()

    ' Get the default print queue
    Dim pq As PrintQueue = ps.DefaultPrintQueue

    ' Get an XpsDocumentWriter for the default print queue
    Dim xpsdw As XpsDocumentWriter = PrintQueue.CreateXpsDocumentWriter(pq)
    Return xpsdw
End Function ' end:GetPrintXpsDocumentWriter()

注解

当应用程序将值写入LocalPrintServer对象的属性时, 在将值传递到由LocalPrintServer对象表示的计算机之前, 该更改将不起作用。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. 若要确保对值所做的更改生效, 请Commit使用方法。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. 若要确保LocalPrintServer应用程序使用的对象具有最新的实际值, 请Refresh使用方法。To ensure that the LocalPrintServer object used by your application has the latest actual values, use the Refresh method.

注意

System.Printing命名空间中的类不支持在 Windows 服务或 ASP.NET 应用程序或服务中使用。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.

如果要从 Windows 窗体应用程序进行打印, 请参阅System.Drawing.Printing命名空间。If you want to print from a Windows Forms application, see the System.Drawing.Printing namespace.

构造函数

LocalPrintServer()

初始化 LocalPrintServer 类的新实例。Initializes a new instance of the LocalPrintServer class.

LocalPrintServer(LocalPrintServerIndexedProperty[])

初始化具有指定 LocalPrintServer 数组的 LocalPrintServerIndexedProperty 类的一个新实例。Initializes a new instance of the LocalPrintServer class that has the specified LocalPrintServerIndexedProperty array.

LocalPrintServer(LocalPrintServerIndexedProperty[], PrintSystemDesiredAccess)

初始化具有指定 LocalPrintServer 数组和指定 LocalPrintServerIndexedPropertyPrintSystemDesiredAccess 类的一个新实例。Initializes a new instance of the LocalPrintServer class that has the specified LocalPrintServerIndexedProperty array and the specified PrintSystemDesiredAccess.

LocalPrintServer(PrintSystemDesiredAccess)

初始化具有指定 LocalPrintServerPrintSystemDesiredAccess 类的新实例。Initializes a new instance of the LocalPrintServer class that has the specified PrintSystemDesiredAccess.

LocalPrintServer(String[])

初始化具有指定属性的 LocalPrintServer 类的一个新实例。Initializes a new instance of the LocalPrintServer class that has the specified properties.

LocalPrintServer(String[], PrintSystemDesiredAccess)

初始化具有指定属性和 LocalPrintServerPrintSystemDesiredAccess 类的一个新实例。Initializes a new instance of the LocalPrintServer class that has the specified properties and PrintSystemDesiredAccess.

属性

BeepEnabled

获取或设置一个值,该值指示打印服务器是否在打印机出现错误情况时发出提示音。Gets or sets a value that indicates whether the print server beeps in response to an error condition in the printer.

(继承自 PrintServer)
DefaultPortThreadPriority

请勿使用。Do not use.

(继承自 PrintServer)
DefaultPrintQueue

获取或设置默认打印队列。Gets or sets the default print queue.

DefaultSchedulerPriority

请勿使用。Do not use.

(继承自 PrintServer)
DefaultSpoolDirectory

获取或设置打印服务器后台文件的路径。Gets or sets the path where the print server's spool files are located.

(继承自 PrintServer)
EventLog

获取或设置打印服务器记录的事件的类型。Gets or sets the type of events that the print server logs.

(继承自 PrintServer)
IsDelayInitialized

获取或设置一个值,该值指示 PrintServer 属性的初始化是否已推迟。Gets or sets a value that indicates whether initialization of the PrintServer properties has been postponed.

(继承自 PrintServer)
IsDisposed

获取或设置一个值,该值指示该对象是否已被释放。Gets or sets a value that indicates whether the object has been disposed.

(继承自 PrintSystemObject)
MajorVersion

获取操作系统的主版本。Gets the major version of the operating system.

(继承自 PrintServer)
MinorVersion

在操作系统的主版本中获取次版本。Gets the minor version within the major version of the operating system.

(继承自 PrintServer)
Name

获取打印服务器的名称。Gets the name of the print server.

(继承自 PrintServer)
NetPopup

获取或设置一个值,该值指示打印作业已完成的通知是发送到打印服务器,还是发送到客户端计算机。Gets 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.

(继承自 PrintServer)
Parent

获取对象的父级。Gets the parent of the object.

(继承自 PrintSystemObject)
PortThreadPriority

获取或设置管理打印机端口 I/O 的进程的线程优先级别。Gets or sets the thread priority for the process that manages I/O through the printer ports.

(继承自 PrintServer)
PropertiesCollection

获取特性和值对的集合。Gets a collection of attribute and value pairs.

(继承自 PrintSystemObject)
RestartJobOnPoolEnabled

获取或设置一个值,该值指示用户在已启用打印机池的情况下发生错误后是否可重新启动作业。Gets or sets a value that indicates whether users can restart jobs after an error occurs if printer pooling is enabled.

(继承自 PrintServer)
RestartJobOnPoolTimeout

获取或设置一个值,该值指示在启用打印机池的情况下发生错误时重新启动作业之前的等待时间。Gets 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.

(继承自 PrintServer)
SchedulerPriority

获取或设置将打印作业从应用程序路由到打印队列的进程的线程优先级别。Gets or sets the thread priority for the process that routes print jobs from applications to print queues.

(继承自 PrintServer)
SubSystemVersion

获取打印后台处理程序系统的版本。Gets the version of the print spooler system.

(继承自 PrintServer)

方法

Commit()

将应用程序对 LocalPrintServer 的属性所做的所有更改写入对象表示的实际打印服务器。Writes any changes that your application made to the properties of the LocalPrintServer to the actual print server that the object represents.

ConnectToPrintQueue(PrintQueue)

连接本地打印服务器和指定的 PrintQueueConnects the local print server to the specified PrintQueue.

ConnectToPrintQueue(String)

连接使用 String 指定的打印队列。Connects to the print queue that is specified by using the String.

DisconnectFromPrintQueue(PrintQueue)

断开本地打印服务器与指定 PrintQueue 的连接。Disconnects the local print server from the specified PrintQueue.

DisconnectFromPrintQueue(String)

断开与 String 中指定打印队列的连接。Disconnects from the print queue that is specified in the String.

Dispose()

释放 PrintSystemObject 使用的所有资源。Releases all resources used by the PrintSystemObject.

(继承自 PrintSystemObject)
Dispose(Boolean)

释放 PrintSystemObject 使用的非托管资源,并选择性地释放托管资源。Releases the unmanaged resources used by the PrintSystemObject and optionally releases the managed resources.

(继承自 PrintSystemObject)
Equals(Object)

确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetDefaultPrintQueue()

返回对 LocalPrintServer 的默认打印队列的引用。Returns a reference to the default print queue of the LocalPrintServer.

GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetPrintQueue(String)

从打印服务器中获取命名打印队列的引用。Obtains a reference to the named print queue from the print server.

(继承自 PrintServer)
GetPrintQueue(String, String[])

从打印服务器中获取指定的打印队列。Gets a specified print queue from the print server.

(继承自 PrintServer)
GetPrintQueues()

获取打印服务器承载的打印队列的集合。Gets the collection of print queues that the print server hosts.

(继承自 PrintServer)
GetPrintQueues(EnumeratedPrintQueueTypes[])

获取在 EnumeratedPrintQueueTypes 中命名并由打印服务器承载的指定类型的打印队列集合。Gets the collection of print queues of the specified types that are named in EnumeratedPrintQueueTypes and hosted by the print server.

(继承自 PrintServer)
GetPrintQueues(PrintQueueIndexedProperty[])

获取由打印服务器承载的且仅在 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.

(继承自 PrintServer)
GetPrintQueues(PrintQueueIndexedProperty[], EnumeratedPrintQueueTypes[])

获取指定类型的打印队列的集合。Gets a collection of print queues of the specified types. 这些打印队列仅在由 PrintQueueIndexedProperty 数组指定的属性中进行初始化。These print queues are only initialized in the properties that are specified in the PrintQueueIndexedProperty array.

(继承自 PrintServer)
GetPrintQueues(String[])

获取由打印服务器承载的以及仅在指定属性中初始化的打印队列的集合。Gets a collection of print queues that are hosted by the print server and that are initialized only in the specified properties.

(继承自 PrintServer)
GetPrintQueues(String[], EnumeratedPrintQueueTypes[])

获取打印队列的集合,这些打印队列具有指定的 EnumeratedPrintQueueTypes 并仅在指定的属性中进行初始化。Gets the collection of print queues, which are of the specified EnumeratedPrintQueueTypes and are initialized only in the specified properties.

(继承自 PrintServer)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
Initialize()

初始化 PrintSystemObject 的属性。Initializes the properties of the PrintSystemObject.

(继承自 PrintSystemObject)
InstallPrintQueue(String, String, String[], String, PrintPropertyDictionary)

在打印服务器上安装打印队列及关联的打印机驱动程序。Installs a print queue, and associated printer driver, on the print server.

(继承自 PrintServer)
InstallPrintQueue(String, String, String[], String, PrintQueueAttributes)

在打印服务器上安装打印队列及关联的打印机驱动程序。Installs a print queue, and associated printer driver, on the print server.

(继承自 PrintServer)
InstallPrintQueue(String, String, String[], String, PrintQueueAttributes, PrintQueueStringProperty, Int32, Int32)

在打印服务器上安装按优先级别排列的打印队列及关联的打印机驱动程序。Installs a prioritized print queue, and associated printer driver, on the print server.

(继承自 PrintServer)
InstallPrintQueue(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.

(继承自 PrintServer)
InternalDispose(Boolean)

释放由 PrintServer 占用的非托管资源并(可选)释放托管资源。Releases the unmanaged resources that are used by the PrintServer and optionally releases the managed resources.

(继承自 PrintServer)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
Refresh()

更新 LocalPrintServer 对象的属性,以便它们的值与对象表示的打印服务器的值匹配。Updates the properties of the LocalPrintServer object so that their values match the values of the print server that the object represents.

ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅