PrintServer.InstallPrintQueue 方法

定义

在打印服务器上安装打印队列及其关联的打印机驱动程序。

重载

InstallPrintQueue(String, String, String[], String, PrintPropertyDictionary)

在打印服务器上安装打印队列及关联的打印机驱动程序。

InstallPrintQueue(String, String, String[], String, PrintQueueAttributes)

在打印服务器上安装打印队列及关联的打印机驱动程序。

InstallPrintQueue(String, String, String[], String, PrintQueueAttributes, PrintQueueStringProperty, Int32, Int32)

在打印服务器上安装按优先级别排列的打印队列及关联的打印机驱动程序。

InstallPrintQueue(String, String, String[], String, PrintQueueAttributes, String, String, String, String, Int32, Int32)

在打印服务器上安装按优先级别排列的共享打印队列及关联的打印机驱动程序。

InstallPrintQueue(String, String, String[], String, PrintPropertyDictionary)

在打印服务器上安装打印队列及关联的打印机驱动程序。

public:
 System::Printing::PrintQueue ^ InstallPrintQueue(System::String ^ printQueueName, System::String ^ driverName, cli::array <System::String ^> ^ portNames, System::String ^ printProcessorName, System::Printing::IndexedProperties::PrintPropertyDictionary ^ initialParameters);
public System.Printing.PrintQueue InstallPrintQueue (string printQueueName, string driverName, string[] portNames, string printProcessorName, System.Printing.IndexedProperties.PrintPropertyDictionary initialParameters);
member this.InstallPrintQueue : string * string * string[] * string * System.Printing.IndexedProperties.PrintPropertyDictionary -> System.Printing.PrintQueue
Public Function InstallPrintQueue (printQueueName As String, driverName As String, portNames As String(), printProcessorName As String, initialParameters As PrintPropertyDictionary) As PrintQueue

参数

printQueueName
String

新队列的名称。

driverName
String

打印机驱动程序的路径和名称。

portNames
String[]

新队列使用的端口的 ID。

printProcessorName
String

打印处理器的名称。

initialParameters
PrintPropertyDictionary

已初始化的参数。

返回

新的 PrintQueue

示例

下面的示例演示如何使用此方法 (从 PrintServer) 继承方法的对象上LocalPrintServer调用,以安装第二台仅在位置、端口和共享状态方面与现有打印机的属性不同的打印机。

LocalPrintServer myLocalPrintServer = new LocalPrintServer(PrintSystemDesiredAccess.AdministrateServer);
PrintQueue sourcePrintQueue = myLocalPrintServer.DefaultPrintQueue;
PrintPropertyDictionary myPrintProperties = sourcePrintQueue.PropertiesCollection;

// Share the new printer using Remove/Add methods
PrintBooleanProperty shared = new PrintBooleanProperty("IsShared", true);
myPrintProperties.Remove("IsShared");
myPrintProperties.Add("IsShared", shared);

// Give the new printer its share name using SetProperty method
PrintStringProperty theShareName = new PrintStringProperty("ShareName", "\"Son of " + sourcePrintQueue.Name +"\"");
myPrintProperties.SetProperty("ShareName", theShareName);

// Specify the physical location of the new printer using Remove/Add methods
PrintStringProperty theLocation = new PrintStringProperty("Location", "the supply room");
myPrintProperties.Remove("Location");
myPrintProperties.Add("Location", theLocation);

// Specify the port for the new printer
String[] port = new String[] { "COM1:" };

// Install the new printer on the local print server
PrintQueue clonedPrinter = myLocalPrintServer.InstallPrintQueue("My clone of " + sourcePrintQueue.Name, "Xerox WCP 35 PS", port, "WinPrint", myPrintProperties);
myLocalPrintServer.Commit();

// Report outcome
Console.WriteLine("{0} in {1} has been installed and shared as {2}", clonedPrinter.Name, clonedPrinter.Location, clonedPrinter.ShareName);
Console.WriteLine("Press Return to continue ...");
Console.ReadLine();
Dim myLocalPrintServer As New LocalPrintServer(PrintSystemDesiredAccess.AdministrateServer)
Dim sourcePrintQueue As PrintQueue = myLocalPrintServer.DefaultPrintQueue
Dim myPrintProperties As PrintPropertyDictionary = sourcePrintQueue.PropertiesCollection

' Share the new printer using Remove/Add methods
Dim [shared] As New PrintBooleanProperty("IsShared", True)
myPrintProperties.Remove("IsShared")
myPrintProperties.Add("IsShared", [shared])

' Give the new printer its share name using SetProperty method
Dim theShareName As New PrintStringProperty("ShareName", """Son of " & sourcePrintQueue.Name & """")
myPrintProperties.SetProperty("ShareName", theShareName)

' Specify the physical location of the new printer using Remove/Add methods
Dim theLocation As New PrintStringProperty("Location", "the supply room")
myPrintProperties.Remove("Location")
myPrintProperties.Add("Location", theLocation)

' Specify the port for the new printer
Dim port() As String = { "COM1:" }


' Install the new printer on the local print server
Dim clonedPrinter As PrintQueue = myLocalPrintServer.InstallPrintQueue("My clone of " & sourcePrintQueue.Name, "Xerox WCP 35 PS", port, "WinPrint", myPrintProperties)
myLocalPrintServer.Commit()

' Report outcome
Console.WriteLine("{0} in {1} has been installed and shared as {2}", clonedPrinter.Name, clonedPrinter.Location, clonedPrinter.ShareName)
Console.WriteLine("Press Return to continue ...")
Console.ReadLine()

适用于

InstallPrintQueue(String, String, String[], String, PrintQueueAttributes)

在打印服务器上安装打印队列及关联的打印机驱动程序。

public:
 System::Printing::PrintQueue ^ InstallPrintQueue(System::String ^ printQueueName, System::String ^ driverName, cli::array <System::String ^> ^ portNames, System::String ^ printProcessorName, System::Printing::PrintQueueAttributes printQueueAttributes);
public System.Printing.PrintQueue InstallPrintQueue (string printQueueName, string driverName, string[] portNames, string printProcessorName, System.Printing.PrintQueueAttributes printQueueAttributes);
member this.InstallPrintQueue : string * string * string[] * string * System.Printing.PrintQueueAttributes -> System.Printing.PrintQueue
Public Function InstallPrintQueue (printQueueName As String, driverName As String, portNames As String(), printProcessorName As String, printQueueAttributes As PrintQueueAttributes) As PrintQueue

参数

printQueueName
String

新队列的名称。

driverName
String

打印机驱动程序的路径和名称。

portNames
String[]

新队列使用的端口的 ID。

printProcessorName
String

打印处理器的名称。

printQueueAttributes
PrintQueueAttributes

新队列的特性,如标志。

返回

新创建的 PrintQueue

适用于

InstallPrintQueue(String, String, String[], String, PrintQueueAttributes, PrintQueueStringProperty, Int32, Int32)

在打印服务器上安装按优先级别排列的打印队列及关联的打印机驱动程序。

public:
 System::Printing::PrintQueue ^ InstallPrintQueue(System::String ^ printQueueName, System::String ^ driverName, cli::array <System::String ^> ^ portNames, System::String ^ printProcessorName, System::Printing::PrintQueueAttributes printQueueAttributes, System::Printing::PrintQueueStringProperty ^ printQueueProperty, int printQueuePriority, int printQueueDefaultPriority);
public System.Printing.PrintQueue InstallPrintQueue (string printQueueName, string driverName, string[] portNames, string printProcessorName, System.Printing.PrintQueueAttributes printQueueAttributes, System.Printing.PrintQueueStringProperty printQueueProperty, int printQueuePriority, int printQueueDefaultPriority);
member this.InstallPrintQueue : string * string * string[] * string * System.Printing.PrintQueueAttributes * System.Printing.PrintQueueStringProperty * int * int -> System.Printing.PrintQueue
Public Function InstallPrintQueue (printQueueName As String, driverName As String, portNames As String(), printProcessorName As String, printQueueAttributes As PrintQueueAttributes, printQueueProperty As PrintQueueStringProperty, printQueuePriority As Integer, printQueueDefaultPriority As Integer) As PrintQueue

参数

printQueueName
String

新队列的名称。

driverName
String

打印机驱动程序的路径和名称。

portNames
String[]

新队列使用的端口的 ID。

printProcessorName
String

打印处理器的名称。

printQueueAttributes
PrintQueueAttributes

新队列的特性,如标志。

printQueueProperty
PrintQueueStringProperty

新队列的注释、位置或共享名称。

printQueuePriority
Int32

一个从 1 到 99 之间的值,指定相对于打印服务器承载的其他队列而言,此打印队列的优先级别。

printQueueDefaultPriority
Int32

一个从 1 到 99 之间的值,指定发送到队列的打印作业的默认优先级别。

返回

新创建的 PrintQueue

注解

printQueueProperty使用 参数可初始化队列的 、 CommentLocation 属性的ShareName一个,并且只能初始化一个。 如果要初始化多个,请使用 InstallPrintQueue(String, String, String[], String, PrintQueueAttributes, String, String, String, String, Int32, Int32) 此方法的重载。

适用于

InstallPrintQueue(String, String, String[], String, PrintQueueAttributes, String, String, String, String, Int32, Int32)

在打印服务器上安装按优先级别排列的共享打印队列及关联的打印机驱动程序。

public:
 System::Printing::PrintQueue ^ InstallPrintQueue(System::String ^ printQueueName, System::String ^ driverName, cli::array <System::String ^> ^ portNames, System::String ^ printProcessorName, System::Printing::PrintQueueAttributes printQueueAttributes, System::String ^ printQueueShareName, System::String ^ printQueueComment, System::String ^ printQueueLocation, System::String ^ printQueueSeparatorFile, int printQueuePriority, int printQueueDefaultPriority);
public System.Printing.PrintQueue InstallPrintQueue (string printQueueName, string driverName, string[] portNames, string printProcessorName, System.Printing.PrintQueueAttributes printQueueAttributes, string printQueueShareName, string printQueueComment, string printQueueLocation, string printQueueSeparatorFile, int printQueuePriority, int printQueueDefaultPriority);
member this.InstallPrintQueue : string * string * string[] * string * System.Printing.PrintQueueAttributes * string * string * string * string * int * int -> System.Printing.PrintQueue
Public Function InstallPrintQueue (printQueueName As String, driverName As String, portNames As String(), printProcessorName As String, printQueueAttributes As PrintQueueAttributes, printQueueShareName As String, printQueueComment As String, printQueueLocation As String, printQueueSeparatorFile As String, printQueuePriority As Integer, printQueueDefaultPriority As Integer) As PrintQueue

参数

printQueueName
String

新队列的名称。

driverName
String

打印机驱动程序的路径和名称。

portNames
String[]

新队列使用的端口的 ID。

printProcessorName
String

打印处理器的名称。

printQueueAttributes
PrintQueueAttributes

新队列的特性,如标志。

printQueueShareName
String

新队列的共享名称。

printQueueComment
String

有关 Microsoft Windows UI 中用户可见的队列的注释。

printQueueLocation
String

新队列的位置。

printQueueSeparatorFile
String

插入各打印作业开头的文件的路径。

printQueuePriority
Int32

一个从 1 到 99 之间的值,指定相对于打印服务器承载的其他队列而言,此队列的优先级别。

printQueueDefaultPriority
Int32

一个从 1 到 99 之间的值,指定发送到队列的新打印作业的默认优先级别。

返回

新创建的 PrintQueue

注解

如果不想初始化队列ShareName的所有三个 、 CommentLocation 属性;可以为 、 和 printQueueLocation中的printQueueShareNameprintQueueComment一个或多个 传递空字符串。 如果只想初始化其中一个属性,请使用 InstallPrintQueue(String, String, String[], String, PrintQueueAttributes, PrintQueueStringProperty, Int32, Int32) 此方法的 重载。

适用于