PrintServer Constructors

Definition

Initializes a new instance of the PrintServer class.

Overloads

PrintServer()

Initializes a new instance of the PrintServer class.

PrintServer(PrintSystemDesiredAccess)

Initializes a new instance of the PrintServer class that represents the local print server and assigns it the specified PrintSystemDesiredAccess.

PrintServer(String)

Initializes a new instance of the PrintServer class that has the specified path.

PrintServer(String, PrintServerIndexedProperty[])

Initializes a new instance of the PrintServer class by using the specified PrintServerIndexedProperty array to determine which properties will be initialized.

PrintServer(String, PrintSystemDesiredAccess)

Initializes a new instance of the PrintServer class that has the specified path and the needed access.

PrintServer(String, String[])

Initializes a new instance of the PrintServer class that has the specified path and properties filter.

PrintServer(String, PrintServerIndexedProperty[], PrintSystemDesiredAccess)

Initializes a new instance of the PrintServer class and provides the specified path, the PrintServerIndexedProperty array, and the needed access.

PrintServer(String, String[], PrintSystemDesiredAccess)

Initializes a new instance of the PrintServer class that has the specified path, properties filter, and the needed access.

PrintServer()

Initializes a new instance of the PrintServer class.

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

Applies to

PrintServer(PrintSystemDesiredAccess)

Initializes a new instance of the PrintServer class that represents the local print server and assigns it the specified 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)

Parameters

desiredAccess
PrintSystemDesiredAccess

A value that specifies the type of print server access that your program needs.

Exceptions

desiredAccess is a value that can be applied only to a PrintQueue object, not a LocalPrintServer object. For example, UsePrinter.

Remarks

The PrintServer will be initialized with the local print server's properties, such as Name.

Applies to

PrintServer(String)

Initializes a new instance of the PrintServer class that has the specified path.

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

Parameters

path
String

The name and complete path of the print server.

Examples

The following example shows how to use this constructor to create an instance of 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()

Remarks

If path is null, the PrintServer will represent the local print server and will be initialized with its properties, such as Name.

Applies to

PrintServer(String, PrintServerIndexedProperty[])

Initializes a new instance of the PrintServer class by using the specified PrintServerIndexedProperty array to determine which properties will be initialized.

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

Parameters

path
String

The complete path and name of the print server.

propertiesFilter
PrintServerIndexedProperty[]

The properties that the constructor initializes.

Remarks

If path is null, the PrintServer will represent the local print server and will be initialized with its properties, such as Name.

Applies to

PrintServer(String, PrintSystemDesiredAccess)

Initializes a new instance of the PrintServer class that has the specified path and the needed access.

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)

Parameters

path
String

The name and complete path of the print server.

desiredAccess
PrintSystemDesiredAccess

A value that specifies the type of print server access that your program needs.

Exceptions

desiredAccess is a value that can be applied only to a PrintQueue object, not a LocalPrintServer object. For example, UsePrinter.

Examples

The following example shows how to use this constructor to survey all printers for possible error status.

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

Remarks

If path is null, the PrintServer will represent the local print server and will be initialized with its properties, such as Name.

Applies to

PrintServer(String, String[])

Initializes a new instance of the PrintServer class that has the specified path and properties filter.

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

Parameters

path
String

The name and complete path of the print server.

propertiesFilter
String[]

An array of the names of properties that the constructor initializes.

Remarks

If path is null, the PrintServer will represent the local print server and will be initialized with its properties, such as Name.

Applies to

PrintServer(String, PrintServerIndexedProperty[], PrintSystemDesiredAccess)

Initializes a new instance of the PrintServer class and provides the specified path, the PrintServerIndexedProperty array, and the needed access.

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)

Parameters

path
String

The complete path and name of the print server.

propertiesFilter
PrintServerIndexedProperty[]

The properties that the constructor initializes.

desiredAccess
PrintSystemDesiredAccess

A value that specifies the type of print server access that your program needs.

Exceptions

desiredAccess is a value that can be applied only to a PrintQueue object, not a LocalPrintServer object. For example, UsePrinter.

Remarks

If path is null, the PrintServer will represent the local print server and will be initialized with its properties, such as Name.

Applies to

PrintServer(String, String[], PrintSystemDesiredAccess)

Initializes a new instance of the PrintServer class that has the specified path, properties filter, and the needed access.

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)

Parameters

path
String

The name and complete path of the print server.

propertiesFilter
String[]

An array of the names of properties that the constructor initializes.

desiredAccess
PrintSystemDesiredAccess

A value that specifies the type of print server access that your program needs.

Exceptions

desiredAccess is a value that can be applied only to a PrintQueue object, not a LocalPrintServer object. For example, UsePrinter.

Remarks

If path is null, the PrintServer will represent the local print server and will be initialized with its properties, such as Name.

Applies to