PrintServer 构造函数

定义

初始化 PrintServer 类的新实例。

重载

PrintServer()

初始化 PrintServer 类的新实例。

PrintServer(PrintSystemDesiredAccess)

初始化表示本地打印服务器的 PrintServer 类的一个新实例,并为其分配指定的 PrintSystemDesiredAccess

PrintServer(String)

初始化具有指定路径的 PrintServer 类的一个新实例。

PrintServer(String, PrintServerIndexedProperty[])

初始化 PrintServer 类的一个新实例,方法是使用指定的 PrintServerIndexedProperty 数组来确定将初始化的属性。

PrintServer(String, PrintSystemDesiredAccess)

初始化具有指定路径和所需访问的 PrintServer 类的一个新实例。

PrintServer(String, String[])

初始化具有指定路径和属性筛选器的 PrintServer 类的一个新实例。

PrintServer(String, PrintServerIndexedProperty[], PrintSystemDesiredAccess)

初始化 PrintServer 类的一个新实例,并提供指定路径、PrintServerIndexedProperty 数组和所需访问。

PrintServer(String, String[], PrintSystemDesiredAccess)

初始化具有指定路径、属性筛选器和所需访问的 PrintServer 类的一个新实例。

PrintServer()

初始化 PrintServer 类的新实例。

public:
 PrintServer();
public PrintServer ();
Public Sub New ()

适用于

PrintServer(PrintSystemDesiredAccess)

初始化表示本地打印服务器的 PrintServer 类的一个新实例,并为其分配指定的 PrintSystemDesiredAccess

public:
 PrintServer(System::Printing::PrintSystemDesiredAccess desiredAccess);
public PrintServer (System.Printing.PrintSystemDesiredAccess desiredAccess);
new System.Printing.PrintServer : System.Printing.PrintSystemDesiredAccess -> System.Printing.PrintServer
Public Sub New (desiredAccess As PrintSystemDesiredAccess)

参数

desiredAccess
PrintSystemDesiredAccess

一个值,指定程序所需的打印服务器访问类型。

例外

desiredAccess 是只能用于 PrintQueue 对象,而不能用于 LocalPrintServer 对象的值。 例如,UsePrinter

注解

PrintServer将使用本地打印服务器的属性(例如 Name)初始化 。

适用于

PrintServer(String)

初始化具有指定路径的 PrintServer 类的一个新实例。

public:
 PrintServer(System::String ^ path);
public PrintServer (string path);
new System.Printing.PrintServer : string -> System.Printing.PrintServer
Public Sub New (path As String)

参数

path
String

打印服务器的名称和完整路径。

示例

以下示例演示如何使用此构造函数创建 的 PrintServer实例。


// Create a PrintServer
// "theServer" must be a print server to which the user has full print access.
PrintServer myPrintServer = new PrintServer(@"\\theServer");

// List the print server's queues
PrintQueueCollection myPrintQueues = myPrintServer.GetPrintQueues();
String printQueueNames = "My Print Queues:\n\n";
foreach (PrintQueue pq in myPrintQueues)
{
    printQueueNames += "\t" + pq.Name + "\n";
}
Console.WriteLine(printQueueNames);
Console.WriteLine("\nPress Return to continue.");
Console.ReadLine();

' Create a PrintServer
' "theServer" must be a print server to which the user has full print access.
Dim myPrintServer As New PrintServer("\\theServer")

' List the print server's queues
Dim myPrintQueues As PrintQueueCollection = myPrintServer.GetPrintQueues()
Dim printQueueNames As String = "My Print Queues:" & vbLf & vbLf
For Each pq As PrintQueue In myPrintQueues
    printQueueNames &= vbTab & pq.Name & vbLf
Next pq
Console.WriteLine(printQueueNames)
Console.WriteLine(vbLf & "Press Return to continue.")
Console.ReadLine()

注解

如果 pathnullPrintServer 则 表示本地打印服务器,并将使用其属性(如 ) Name进行初始化。

适用于

PrintServer(String, PrintServerIndexedProperty[])

初始化 PrintServer 类的一个新实例,方法是使用指定的 PrintServerIndexedProperty 数组来确定将初始化的属性。

public:
 PrintServer(System::String ^ path, cli::array <System::Printing::PrintServerIndexedProperty> ^ propertiesFilter);
public PrintServer (string path, System.Printing.PrintServerIndexedProperty[] propertiesFilter);
new System.Printing.PrintServer : string * System.Printing.PrintServerIndexedProperty[] -> System.Printing.PrintServer
Public Sub New (path As String, propertiesFilter As PrintServerIndexedProperty())

参数

path
String

打印服务器的完整路径和名称。

propertiesFilter
PrintServerIndexedProperty[]

此构造函数初始化的属性。

注解

如果 pathnullPrintServer 则 表示本地打印服务器,并将使用其属性(如 ) Name进行初始化。

适用于

PrintServer(String, PrintSystemDesiredAccess)

初始化具有指定路径和所需访问的 PrintServer 类的一个新实例。

public:
 PrintServer(System::String ^ path, System::Printing::PrintSystemDesiredAccess desiredAccess);
public PrintServer (string path, System.Printing.PrintSystemDesiredAccess desiredAccess);
new System.Printing.PrintServer : string * System.Printing.PrintSystemDesiredAccess -> System.Printing.PrintServer
Public Sub New (path As String, desiredAccess As PrintSystemDesiredAccess)

参数

path
String

打印服务器的名称和完整路径。

desiredAccess
PrintSystemDesiredAccess

一个值,指定程序所需的打印服务器访问类型。

例外

desiredAccess 是只能用于 PrintQueue 对象,而不能用于 LocalPrintServer 对象的值。 例如,UsePrinter

示例

以下示例演示如何使用此构造函数来调查所有打印机的可能错误状态。

// Survey queue status for every queue on every print server
System::String^ line;
System::String^ statusReport = "\n\nAny problem states are indicated below:\n\n";
while ((line = fileOfPrintServers->ReadLine()) != nullptr)
{
   System::Printing::PrintServer^ myPS = gcnew System::Printing::PrintServer(line, PrintSystemDesiredAccess::AdministrateServer);
   System::Printing::PrintQueueCollection^ myPrintQueues = myPS->GetPrintQueues();
   statusReport = statusReport + "\n" + line;
   for each (System::Printing::PrintQueue^ pq in myPrintQueues)
   {
      pq->Refresh();
      statusReport = statusReport + "\n\t" + pq->Name + ":";
      if (useAttributesResponse == "y")
      {
         TroubleSpotter::SpotTroubleUsingQueueAttributes(statusReport, pq);
         // TroubleSpotter class is defined in the complete example.
      } else
      {
         TroubleSpotter::SpotTroubleUsingProperties(statusReport, pq);
      }
   }
}
fileOfPrintServers->Close();
Console::WriteLine(statusReport);
Console::WriteLine("\nPress Return to continue.");
Console::ReadLine();
// Survey queue status for every queue on every print server
String line;
String statusReport = "\n\nAny problem states are indicated below:\n\n";
while ((line = fileOfPrintServers.ReadLine()) != null)
 {
     PrintServer myPS = new PrintServer(line, PrintSystemDesiredAccess.AdministrateServer);
     PrintQueueCollection myPrintQueues = myPS.GetPrintQueues();
     statusReport = statusReport + "\n" + line;
     foreach (PrintQueue pq in myPrintQueues)
     {
         pq.Refresh();
         statusReport = statusReport + "\n\t" + pq.Name + ":";
         if (useAttributesResponse == "y")
         {
             TroubleSpotter.SpotTroubleUsingQueueAttributes(ref statusReport, pq);
             // TroubleSpotter class is defined in the complete example.
         }
         else
         {
             TroubleSpotter.SpotTroubleUsingProperties(ref statusReport, pq);
         }                 
     }// end for each print queue
 }// end while list of print servers is not yet exhausted

fileOfPrintServers.Close();
Console.WriteLine(statusReport);
Console.WriteLine("\nPress Return to continue.");
Console.ReadLine();
' Survey queue status for every queue on every print server
Dim line As String
Dim statusReport As String = vbLf & vbLf & "Any problem states are indicated below:" & vbLf & vbLf
line = fileOfPrintServers.ReadLine()
Do While line IsNot Nothing
     Dim myPS As New PrintServer(line, PrintSystemDesiredAccess.AdministrateServer)
     Dim myPrintQueues As PrintQueueCollection = myPS.GetPrintQueues()
     statusReport = statusReport & vbLf & line
     For Each pq As PrintQueue In myPrintQueues
         pq.Refresh()
         statusReport = statusReport & vbLf & vbTab & pq.Name & ":"
         If useAttributesResponse = "y" Then
             TroubleSpotter.SpotTroubleUsingQueueAttributes(statusReport, pq)
             ' TroubleSpotter class is defined in the complete example.
         Else
             TroubleSpotter.SpotTroubleUsingProperties(statusReport, pq)
         End If

     Next pq ' end for each print queue

    line = fileOfPrintServers.ReadLine()
Loop ' end while list of print servers is not yet exhausted

fileOfPrintServers.Close()
Console.WriteLine(statusReport)
Console.WriteLine(vbLf & "Press Return to continue.")
Console.ReadLine()

注解

如果 pathnullPrintServer 则 表示本地打印服务器,并将使用其属性(如 ) Name进行初始化。

适用于

PrintServer(String, String[])

初始化具有指定路径和属性筛选器的 PrintServer 类的一个新实例。

public:
 PrintServer(System::String ^ path, cli::array <System::String ^> ^ propertiesFilter);
public PrintServer (string path, string[] propertiesFilter);
new System.Printing.PrintServer : string * string[] -> System.Printing.PrintServer
Public Sub New (path As String, propertiesFilter As String())

参数

path
String

打印服务器的名称和完整路径。

propertiesFilter
String[]

构造函数初始化的属性名称数组。

注解

如果 pathnullPrintServer 则 表示本地打印服务器,并将使用其属性(如 ) Name进行初始化。

适用于

PrintServer(String, PrintServerIndexedProperty[], PrintSystemDesiredAccess)

初始化 PrintServer 类的一个新实例,并提供指定路径、PrintServerIndexedProperty 数组和所需访问。

public:
 PrintServer(System::String ^ path, cli::array <System::Printing::PrintServerIndexedProperty> ^ propertiesFilter, System::Printing::PrintSystemDesiredAccess desiredAccess);
public PrintServer (string path, System.Printing.PrintServerIndexedProperty[] propertiesFilter, System.Printing.PrintSystemDesiredAccess desiredAccess);
new System.Printing.PrintServer : string * System.Printing.PrintServerIndexedProperty[] * System.Printing.PrintSystemDesiredAccess -> System.Printing.PrintServer
Public Sub New (path As String, propertiesFilter As PrintServerIndexedProperty(), desiredAccess As PrintSystemDesiredAccess)

参数

path
String

打印服务器的完整路径和名称。

propertiesFilter
PrintServerIndexedProperty[]

此构造函数初始化的属性。

desiredAccess
PrintSystemDesiredAccess

一个值,指定程序所需的打印服务器访问类型。

例外

desiredAccess 是只能用于 PrintQueue 对象,而不能用于 LocalPrintServer 对象的值。 例如,UsePrinter

注解

如果 pathnullPrintServer 则 表示本地打印服务器,并将使用其属性(如 ) Name进行初始化。

适用于

PrintServer(String, String[], PrintSystemDesiredAccess)

初始化具有指定路径、属性筛选器和所需访问的 PrintServer 类的一个新实例。

public:
 PrintServer(System::String ^ path, cli::array <System::String ^> ^ propertiesFilter, System::Printing::PrintSystemDesiredAccess desiredAccess);
public PrintServer (string path, string[] propertiesFilter, System.Printing.PrintSystemDesiredAccess desiredAccess);
new System.Printing.PrintServer : string * string[] * System.Printing.PrintSystemDesiredAccess -> System.Printing.PrintServer
Public Sub New (path As String, propertiesFilter As String(), desiredAccess As PrintSystemDesiredAccess)

参数

path
String

打印服务器的名称和完整路径。

propertiesFilter
String[]

构造函数初始化的属性名称数组。

desiredAccess
PrintSystemDesiredAccess

一个值,指定程序所需的打印服务器访问类型。

例外

desiredAccess 是只能用于 PrintQueue 对象,而不能用于 LocalPrintServer 对象的值。 例如,UsePrinter

注解

如果 pathnullPrintServer 则 表示本地打印服务器,并将使用其属性(如 ) Name进行初始化。

适用于