共用方式為


PrintServer 建構函式

定義

初始化 PrintServer 類別的新執行個體。

多載

PrintServer()

初始化 PrintServer 類別的新執行個體。

PrintServer(PrintSystemDesiredAccess)

初始化表示本機列印伺服器並指派它為指定 PrintServerPrintSystemDesiredAccess 類別的新執行個體。

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)

初始化表示本機列印伺服器並指派它為指定 PrintServerPrintSystemDesiredAccess 類別的新執行個體。

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

備註

如果 pathnull,則 PrintServer 表示本機印表伺服器,並使用其屬性初始化,例如 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[]

建構函式初始化的屬性。

備註

如果 pathnull,則 PrintServer 表示本機印表伺服器,並使用其屬性初始化,例如 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()

備註

如果 pathnull,則 PrintServer 表示本機印表伺服器,並使用其屬性初始化,例如 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[]

建構函式初始化的屬性名稱陣列。

備註

如果 pathnull,則 PrintServer 表示本機印表伺服器,並使用其屬性初始化,例如 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

備註

如果 pathnull,則 PrintServer 表示本機印表伺服器,並使用其屬性初始化,例如 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

備註

如果 pathnull,則 PrintServer 表示本機印表伺服器,並使用其屬性初始化,例如 Name

適用於