PrintQueue.UntilTimeOfDay 属性

定义

获取或设置打印机打印作业的最晚时间,用协调世界时 (UTC)(也称格林尼治标准时间 [GMT])午夜过后的分钟数表示。

public:
 virtual property int UntilTimeOfDay { int get(); void set(int value); };
public virtual int UntilTimeOfDay { get; set; }
member this.UntilTimeOfDay : int with get, set
Public Overridable Property UntilTimeOfDay As Integer

属性值

一天中不再使用打印机的时间,用午夜 (UTC) 过后的分钟数表示。 最大值为 1439。 首次使用 Microsoft Windows 添加打印机向导安装打印机时,打印机默认为随时可用,此属性在所有时区中返回 0。

示例

以下示例演示如何使用此属性来确定打印机目前是否可用。

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

注解

如果你不在 UTC 时区中,则必须添加或减去 60 的倍数,以便为时区设置或获取正确的时间。 例如,如果位于太平洋时区北美且夏令时无效,则本地时间比 UTC 早 8 小时。 若要将时区中的上午 12 点设置为 UntilTimeOfDay 8 AM UTC,即 480 (= 8 * 60) 。 还必须记住,时间在) 第 24 小时 (第 1439 分钟后滚动到零。 若要在时区中将其设置为下午 6 点,请将它设置为 UTC 凌晨 2 点,即 120 (= 2 * 60) 。 有关有用的时区操作方法,请参阅 TimeZoneTimeSpanDateTime 类。

如果打印机始终可用,则此属性在所有时区中返回 0。

适用于

另请参阅