Procedura: verificare lo stato delle stampanti da postazione remotaHow to: Remotely Survey the Status of Printers

In qualsiasi momento in aziende di medie e grandi dimensioni potrebbero essere presenti più stampanti non funzionanti a causa di fogli bloccati o carta esaurita o un'altra situazione problematica.At any given time at medium and large companies there may be multiple printers that are not working due to a paper jam or being out of paper or some other problematic situation. Il set completo di proprietà della stampante esposte nel APIAPIs di Microsoft .NET Framework forniscono un mezzo per l'esecuzione di un sondaggio rapido degli stati delle stampanti.The rich set of printer properties exposed in the APIAPIs of Microsoft .NET Framework provide a means for performing a rapid survey of the states of printers.

EsempioExample

Di seguito sono indicati i passaggi principali per la creazione di questo tipo di utilità.The major steps for creating this kind of utility are as follows.

  1. Ottenere un elenco di tutti i server di stampa.Obtain a list of all print servers.

  2. Scorrere i server per eseguire una query sulle code di stampa.Loop through the servers to query their print queues.

  3. In ogni passaggio del ciclo del server, scorrere tutte le code del server e leggere tutte le proprietà che potrebbero indicare che la coda attualmente non funziona.Within each pass of the server loop, loop through all the server's queues and read each property that might indicate that the queue is not currently working.

Il codice seguente è una serie di frammenti di codice.The code below is a series of snippets. Per semplicità, in questo esempio si presuppone che esista un elenco delimitato da CRLF di server di stampa.For simplicity, this example assumes that there is a CRLF-delimited list of print servers. La variabile fileOfPrintServers è un StreamReader oggetto per il file.The variable fileOfPrintServers is a StreamReader object for this file. Poiché ogni nome del server su una riga distinta, qualsiasi chiamata di ReadLine Ottiene il nome del server successivo e passa il StreamReaderdel cursore all'inizio della riga successiva.Since each server name is on its own line, any call of ReadLine gets the name of the next server and moves the StreamReader's cursor to the beginning of the next line.

All'interno del ciclo esterno, il codice crea un PrintServer dell'oggetto per l'ultimo server di stampa e specifica che l'applicazione deve disporre di diritti amministrativi per il server.Within the outer loop, the code creates a PrintServer object for the latest print server and specifies that the application is to have administrative rights to the server.

Nota

Se sono presenti molti server, è possibile migliorare le prestazioni utilizzando il PrintServer(String, String[], PrintSystemDesiredAccess) costruttori che inizializzano solo le proprietà che si intende necessario.If there are a lot of servers, you can improve performance by using the PrintServer(String, String[], PrintSystemDesiredAccess) constructors that only initialize the properties you are going to need.

Nell'esempio viene quindi utilizzato GetPrintQueues per creare una raccolta di tutti i server del Accoda e inizia a eseguire un ciclo.The example then uses GetPrintQueues to create a collection of all of the server's queues and begins to loop through them. Il ciclo interno include una struttura ramificata corrispondente ai due metodi di verifica dello stato della stampante:This inner loop contains a branching structure corresponding to the two ways of checking a printer's status:

Questo esempio illustra entrambi i metodi, in modo che l'utente in precedenza è stato richiesto il metodo da usare e ha risposto con "y" se desidera utilizzare i flag del QueueStatus proprietà.This example demonstrates both methods, so the user was previously prompted as to which method to use and responded with "y" if he or she wanted to use the flags of the QueueStatus property. Per i dettagli dei due metodi, vedere di seguito.See below for the details of the two methods.

Infine, i risultati vengono presentati all'utente.Finally, the results are presented to the user.

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

Per controllare lo stato della stampante utilizzando il flag della QueueStatus proprietà, si verifica ogni flag pertinente per verificare se è impostato.To check printer status using the flags of the QueueStatus property, you check each relevant flag to see if it is set. Il metodo standard per verificare se un bit è impostato in un set di flag di bit consiste nell'eseguire un'operazione di AND logico con il set di flag come uno degli operandi e il flag stesso come altro operando.The standard way to see if one bit is set in a set of bit flags is to perform a logical AND operation with the set of flags as one operand and the flag itself as the other. Poiché il flag stesso ha un solo bit impostato, il risultato dell'AND logico è che, al massimo, è impostato quello stesso bit.Since the flag itself has only one bit set, the result of the logical AND is that, at most, that same bit is set. Per verificare se lo è o meno, confrontare il risultato dell’AND logico con il flag stesso.To find out whether it is or not, just compare the result of the logical AND with the flag itself. Per ulteriori informazioni, vedere PrintQueueStatus, & (operatore) (riferimenti per c#), e FlagsAttribute.For more information, see PrintQueueStatus, the & Operator (C# Reference), and FlagsAttribute.

Per ogni attributo il cui bit è impostato, il codice aggiunge un avviso al report finale che verrà presentato all'utente.For each attribute whose bit is set, the code adds a notice to the final report that will be presented to the user. (Il metodo ReportAvailabilityAtThisTime che viene chiamato alla fine del codice è illustrato di seguito.)(The ReportAvailabilityAtThisTime method that is called at the end of the code is discussed below.)

internal: 
   // Check for possible trouble states of a printer using the flags of the QueueStatus property
   static void SpotTroubleUsingQueueAttributes (System::String^% statusReport, System::Printing::PrintQueue^ pq) 
   {
      if ((pq->QueueStatus & PrintQueueStatus::PaperProblem) == PrintQueueStatus::PaperProblem)
      {
         statusReport = statusReport + "Has a paper problem. ";
      }
      if ((pq->QueueStatus & PrintQueueStatus::NoToner) == PrintQueueStatus::NoToner)
      {
         statusReport = statusReport + "Is out of toner. ";
      }
      if ((pq->QueueStatus & PrintQueueStatus::DoorOpen) == PrintQueueStatus::DoorOpen)
      {
         statusReport = statusReport + "Has an open door. ";
      }
      if ((pq->QueueStatus & PrintQueueStatus::Error) == PrintQueueStatus::Error)
      {
         statusReport = statusReport + "Is in an error state. ";
      }
      if ((pq->QueueStatus & PrintQueueStatus::NotAvailable) == PrintQueueStatus::NotAvailable)
      {
         statusReport = statusReport + "Is not available. ";
      }
      if ((pq->QueueStatus & PrintQueueStatus::Offline) == PrintQueueStatus::Offline)
      {
         statusReport = statusReport + "Is off line. ";
      }
      if ((pq->QueueStatus & PrintQueueStatus::OutOfMemory) == PrintQueueStatus::OutOfMemory)
      {
         statusReport = statusReport + "Is out of memory. ";
      }
      if ((pq->QueueStatus & PrintQueueStatus::PaperOut) == PrintQueueStatus::PaperOut)
      {
         statusReport = statusReport + "Is out of paper. ";
      }
      if ((pq->QueueStatus & PrintQueueStatus::OutputBinFull) == PrintQueueStatus::OutputBinFull)
      {
         statusReport = statusReport + "Has a full output bin. ";
      }
      if ((pq->QueueStatus & PrintQueueStatus::PaperJam) == PrintQueueStatus::PaperJam)
      {
         statusReport = statusReport + "Has a paper jam. ";
      }
      if ((pq->QueueStatus & PrintQueueStatus::Paused) == PrintQueueStatus::Paused)
      {
         statusReport = statusReport + "Is paused. ";
      }
      if ((pq->QueueStatus & PrintQueueStatus::TonerLow) == PrintQueueStatus::TonerLow)
      {
         statusReport = statusReport + "Is low on toner. ";
      }
      if ((pq->QueueStatus & PrintQueueStatus::UserIntervention) == PrintQueueStatus::UserIntervention)
      {
         statusReport = statusReport + "Needs user intervention. ";
      }

      // Check if queue is even available at this time of day
      // The method below is defined in the complete example.
      ReportAvailabilityAtThisTime(statusReport, pq);
   };
// Check for possible trouble states of a printer using the flags of the QueueStatus property
internal static void SpotTroubleUsingQueueAttributes(ref String statusReport, PrintQueue pq)
{
    if ((pq.QueueStatus & PrintQueueStatus.PaperProblem) == PrintQueueStatus.PaperProblem)
    {
        statusReport = statusReport + "Has a paper problem. ";
    }
    if ((pq.QueueStatus & PrintQueueStatus.NoToner) == PrintQueueStatus.NoToner)
    {
        statusReport = statusReport + "Is out of toner. ";
    }
    if ((pq.QueueStatus & PrintQueueStatus.DoorOpen) == PrintQueueStatus.DoorOpen)
    {
        statusReport = statusReport + "Has an open door. ";
    }
    if ((pq.QueueStatus & PrintQueueStatus.Error) == PrintQueueStatus.Error)
    {
        statusReport = statusReport + "Is in an error state. ";
    }
    if ((pq.QueueStatus & PrintQueueStatus.NotAvailable) == PrintQueueStatus.NotAvailable)
    {
        statusReport = statusReport + "Is not available. ";
    }
    if ((pq.QueueStatus & PrintQueueStatus.Offline) == PrintQueueStatus.Offline)
    {
        statusReport = statusReport + "Is off line. ";
    }
    if ((pq.QueueStatus & PrintQueueStatus.OutOfMemory) == PrintQueueStatus.OutOfMemory)
    {
        statusReport = statusReport + "Is out of memory. ";
    }
    if ((pq.QueueStatus & PrintQueueStatus.PaperOut) == PrintQueueStatus.PaperOut)
    {
        statusReport = statusReport + "Is out of paper. ";
    }
    if ((pq.QueueStatus & PrintQueueStatus.OutputBinFull) == PrintQueueStatus.OutputBinFull)
    {
        statusReport = statusReport + "Has a full output bin. ";
    }
    if ((pq.QueueStatus & PrintQueueStatus.PaperJam) == PrintQueueStatus.PaperJam)
    {
        statusReport = statusReport + "Has a paper jam. ";
    }
    if ((pq.QueueStatus & PrintQueueStatus.Paused) == PrintQueueStatus.Paused)
    {
        statusReport = statusReport + "Is paused. ";
    }
    if ((pq.QueueStatus & PrintQueueStatus.TonerLow) == PrintQueueStatus.TonerLow)
    {
        statusReport = statusReport + "Is low on toner. ";
    }
    if ((pq.QueueStatus & PrintQueueStatus.UserIntervention) == PrintQueueStatus.UserIntervention)
    {
        statusReport = statusReport + "Needs user intervention. ";
    }

    // Check if queue is even available at this time of day
    // The method below is defined in the complete example.
    ReportAvailabilityAtThisTime(ref statusReport, pq);
}
' Check for possible trouble states of a printer using the flags of the QueueStatus property
Friend Shared Sub SpotTroubleUsingQueueAttributes(ByRef statusReport As String, ByVal pq As PrintQueue)
	If (pq.QueueStatus And PrintQueueStatus.PaperProblem) = PrintQueueStatus.PaperProblem Then
		statusReport = statusReport & "Has a paper problem. "
	End If
	If (pq.QueueStatus And PrintQueueStatus.NoToner) = PrintQueueStatus.NoToner Then
		statusReport = statusReport & "Is out of toner. "
	End If
	If (pq.QueueStatus And PrintQueueStatus.DoorOpen) = PrintQueueStatus.DoorOpen Then
		statusReport = statusReport & "Has an open door. "
	End If
	If (pq.QueueStatus And PrintQueueStatus.Error) = PrintQueueStatus.Error Then
		statusReport = statusReport & "Is in an error state. "
	End If
	If (pq.QueueStatus And PrintQueueStatus.NotAvailable) = PrintQueueStatus.NotAvailable Then
		statusReport = statusReport & "Is not available. "
	End If
	If (pq.QueueStatus And PrintQueueStatus.Offline) = PrintQueueStatus.Offline Then
		statusReport = statusReport & "Is off line. "
	End If
	If (pq.QueueStatus And PrintQueueStatus.OutOfMemory) = PrintQueueStatus.OutOfMemory Then
		statusReport = statusReport & "Is out of memory. "
	End If
	If (pq.QueueStatus And PrintQueueStatus.PaperOut) = PrintQueueStatus.PaperOut Then
		statusReport = statusReport & "Is out of paper. "
	End If
	If (pq.QueueStatus And PrintQueueStatus.OutputBinFull) = PrintQueueStatus.OutputBinFull Then
		statusReport = statusReport & "Has a full output bin. "
	End If
	If (pq.QueueStatus And PrintQueueStatus.PaperJam) = PrintQueueStatus.PaperJam Then
		statusReport = statusReport & "Has a paper jam. "
	End If
	If (pq.QueueStatus And PrintQueueStatus.Paused) = PrintQueueStatus.Paused Then
		statusReport = statusReport & "Is paused. "
	End If
	If (pq.QueueStatus And PrintQueueStatus.TonerLow) = PrintQueueStatus.TonerLow Then
		statusReport = statusReport & "Is low on toner. "
	End If
	If (pq.QueueStatus And PrintQueueStatus.UserIntervention) = PrintQueueStatus.UserIntervention Then
		statusReport = statusReport & "Needs user intervention. "
	End If

	' Check if queue is even available at this time of day
	' The method below is defined in the complete example.
	ReportAvailabilityAtThisTime(statusReport, pq)
End Sub

Per controllare lo stato delle stampanti usando tutte le proprietà, basta leggere tutte le proprietà e aggiungere una nota alla relazione finale che sarà presentata all'utente se la proprietà è true.To check printer status using each property, you simply read each property and add a note to the final report that will be presented to the user if the property is true. (Il metodo ReportAvailabilityAtThisTime che viene chiamato alla fine del codice è illustrato di seguito.)(The ReportAvailabilityAtThisTime method that is called at the end of the code is discussed below.)

internal: 
   // Check for possible trouble states of a printer using its properties
   static void SpotTroubleUsingProperties (System::String^% statusReport, System::Printing::PrintQueue^ pq) 
   {
      if (pq->HasPaperProblem)
      {
         statusReport = statusReport + "Has a paper problem. ";
      }
      if (!(pq->HasToner))
      {
         statusReport = statusReport + "Is out of toner. ";
      }
      if (pq->IsDoorOpened)
      {
         statusReport = statusReport + "Has an open door. ";
      }
      if (pq->IsInError)
      {
         statusReport = statusReport + "Is in an error state. ";
      }
      if (pq->IsNotAvailable)
      {
         statusReport = statusReport + "Is not available. ";
      }
      if (pq->IsOffline)
      {
         statusReport = statusReport + "Is off line. ";
      }
      if (pq->IsOutOfMemory)
      {
         statusReport = statusReport + "Is out of memory. ";
      }
      if (pq->IsOutOfPaper)
      {
         statusReport = statusReport + "Is out of paper. ";
      }
      if (pq->IsOutputBinFull)
      {
         statusReport = statusReport + "Has a full output bin. ";
      }
      if (pq->IsPaperJammed)
      {
         statusReport = statusReport + "Has a paper jam. ";
      }
      if (pq->IsPaused)
      {
         statusReport = statusReport + "Is paused. ";
      }
      if (pq->IsTonerLow)
      {
         statusReport = statusReport + "Is low on toner. ";
      }
      if (pq->NeedUserIntervention)
      {
         statusReport = statusReport + "Needs user intervention. ";
      }

      // Check if queue is even available at this time of day
      // The following method is defined in the complete example.
      ReportAvailabilityAtThisTime(statusReport, pq);
   };
// Check for possible trouble states of a printer using its properties
internal static void SpotTroubleUsingProperties(ref String statusReport, PrintQueue pq)
{
    if (pq.HasPaperProblem)
    {
        statusReport = statusReport + "Has a paper problem. ";
    }
    if (!(pq.HasToner))
    {
        statusReport = statusReport + "Is out of toner. ";
    }
    if (pq.IsDoorOpened)
    {
        statusReport = statusReport + "Has an open door. ";
    }
    if (pq.IsInError)
    {
        statusReport = statusReport + "Is in an error state. ";
    }
    if (pq.IsNotAvailable)
    {
        statusReport = statusReport + "Is not available. ";
    }
    if (pq.IsOffline)
    {
        statusReport = statusReport + "Is off line. ";
    }
    if (pq.IsOutOfMemory)
    {
        statusReport = statusReport + "Is out of memory. ";
    }
    if (pq.IsOutOfPaper)
    {
        statusReport = statusReport + "Is out of paper. ";
    }
    if (pq.IsOutputBinFull)
    {
        statusReport = statusReport + "Has a full output bin. ";
    }
    if (pq.IsPaperJammed)
    {
        statusReport = statusReport + "Has a paper jam. ";
    }
    if (pq.IsPaused)
    {
        statusReport = statusReport + "Is paused. ";
    }
    if (pq.IsTonerLow)
    {
        statusReport = statusReport + "Is low on toner. ";
    }
    if (pq.NeedUserIntervention)
    {
        statusReport = statusReport + "Needs user intervention. ";
    }

    // Check if queue is even available at this time of day
    // The following method is defined in the complete example.
    ReportAvailabilityAtThisTime(ref statusReport, pq);

}//end SpotTroubleUsingProperties
' Check for possible trouble states of a printer using its properties
Friend Shared Sub SpotTroubleUsingProperties(ByRef statusReport As String, ByVal pq As PrintQueue)
	If pq.HasPaperProblem Then
		statusReport = statusReport & "Has a paper problem. "
	End If
	If Not(pq.HasToner) Then
		statusReport = statusReport & "Is out of toner. "
	End If
	If pq.IsDoorOpened Then
		statusReport = statusReport & "Has an open door. "
	End If
	If pq.IsInError Then
		statusReport = statusReport & "Is in an error state. "
	End If
	If pq.IsNotAvailable Then
		statusReport = statusReport & "Is not available. "
	End If
	If pq.IsOffline Then
		statusReport = statusReport & "Is off line. "
	End If
	If pq.IsOutOfMemory Then
		statusReport = statusReport & "Is out of memory. "
	End If
	If pq.IsOutOfPaper Then
		statusReport = statusReport & "Is out of paper. "
	End If
	If pq.IsOutputBinFull Then
		statusReport = statusReport & "Has a full output bin. "
	End If
	If pq.IsPaperJammed Then
		statusReport = statusReport & "Has a paper jam. "
	End If
	If pq.IsPaused Then
		statusReport = statusReport & "Is paused. "
	End If
	If pq.IsTonerLow Then
		statusReport = statusReport & "Is low on toner. "
	End If
	If pq.NeedUserIntervention Then
		statusReport = statusReport & "Needs user intervention. "
	End If

	' Check if queue is even available at this time of day
	' The following method is defined in the complete example.
	ReportAvailabilityAtThisTime(statusReport, pq)

End Sub 'end SpotTroubleUsingProperties

Il metodo ReportAvailabilityAtThisTime è stato creato nel caso in cui sia necessario determinare se la coda è disponibile in quel momento preciso del giorno.The ReportAvailabilityAtThisTime method was created in case you need to determine if the queue is available at the current time of day.

Il metodo non ha alcun effetto se la StartTimeOfDay e UntilTimeOfDay le proprietà sono uguali; in quanto in tal caso la stampante è disponibile in qualsiasi momento.The method will do nothing if the StartTimeOfDay and UntilTimeOfDay properties are equal; because in that case the printer is available at all times. Se sono diversi, il metodo ottiene l'ora corrente, che deve quindi essere convertita nel numero totale di minuti trascorsi dalla mezzanotte, poiché il StartTimeOfDay e UntilTimeOfDay sono proprietà Int32che rappresentano i minuti dopo mezzanotte non DateTime oggetti.If they are different, the method gets the current time which then has to be converted into total minutes past midnight because the StartTimeOfDay and UntilTimeOfDay properties are Int32s representing minutes-after-midnight, not DateTime objects. Infine, il metodo controlla se l'ora corrente è compresa tra l'inizio e il lasso di tempo "fino a".Finally, the method checks to see if the current time is between the start and "until" times.

private: 
   static void ReportAvailabilityAtThisTime (System::String^% statusReport, System::Printing::PrintQueue^ pq) 
   {
      if (pq->StartTimeOfDay != pq->UntilTimeOfDay)
      {
         System::DateTime utcNow = DateTime::UtcNow;
         System::Int32 utcNowAsMinutesAfterMidnight = (utcNow.TimeOfDay.Hours * 60) + utcNow.TimeOfDay.Minutes;

         // If now is not within the range of available times . . .
         if (!((pq->StartTimeOfDay < utcNowAsMinutesAfterMidnight) && (utcNowAsMinutesAfterMidnight < pq->UntilTimeOfDay)))
         {
            statusReport = statusReport + " Is not available at this time of day. ";
         }
      }
   };
      private static void ReportAvailabilityAtThisTime(ref String statusReport, PrintQueue pq)
      {
          if (pq.StartTimeOfDay != pq.UntilTimeOfDay) // If the printer is not available 24 hours a day
          {
DateTime utcNow = DateTime.UtcNow;
Int32 utcNowAsMinutesAfterMidnight = (utcNow.TimeOfDay.Hours * 60) + utcNow.TimeOfDay.Minutes;
              
              // If now is not within the range of available times . . .
              if (!((pq.StartTimeOfDay < utcNowAsMinutesAfterMidnight) 
                 &&
                 (utcNowAsMinutesAfterMidnight < pq.UntilTimeOfDay)))
              {
                  statusReport = statusReport + " Is not available at this time of day. ";
              }
          }
      }
Private Shared Sub ReportAvailabilityAtThisTime(ByRef statusReport As String, ByVal pq As PrintQueue)
	If pq.StartTimeOfDay <> pq.UntilTimeOfDay Then ' If the printer is not available 24 hours a day
Dim utcNow As Date = Date.UtcNow
Dim utcNowAsMinutesAfterMidnight As Int32 = (utcNow.TimeOfDay.Hours * 60) + utcNow.TimeOfDay.Minutes

		' If now is not within the range of available times . . .
		If Not((pq.StartTimeOfDay < utcNowAsMinutesAfterMidnight) AndAlso (utcNowAsMinutesAfterMidnight < pq.UntilTimeOfDay)) Then
			statusReport = statusReport & " Is not available at this time of day. "
		End If
	End If
End Sub

Vedere ancheSee Also

StartTimeOfDay
UntilTimeOfDay
DateTime
PrintQueueStatus
FlagsAttribute
GetPrintQueues
PrintServer
LocalPrintServer
EnumeratedPrintQueueTypes
PrintQueue
& (Operatore) (riferimenti per c#)& Operator (C# Reference)
Documenti in WPFDocuments in WPF
Panoramica della stampaPrinting Overview